splent-framework 1.26.0__tar.gz → 1.28.0__tar.gz
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.
- {splent_framework-1.26.0/src/splent_framework.egg-info → splent_framework-1.28.0}/PKG-INFO +2 -1
- {splent_framework-1.26.0 → splent_framework-1.28.0}/README.md +1 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/pyproject.toml +1 -1
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/assets/asset_registry.py +113 -5
- splent_framework-1.28.0/src/splent_framework/assets/feature_assets.py +327 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/hooks/template_hooks.py +22 -4
- splent_framework-1.28.0/src/splent_framework/managers/csp.py +225 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/feature_manager.py +37 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/jinja_manager.py +9 -1
- splent_framework-1.28.0/src/splent_framework/managers/mapper_guard.py +127 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/security_headers_manager.py +26 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/static_cache_manager.py +13 -2
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/nav/menu_registry.py +45 -1
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/params/schema.py +6 -3
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/utils/pyproject_reader.py +8 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0/src/splent_framework.egg-info}/PKG-INFO +2 -1
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework.egg-info/SOURCES.txt +6 -0
- splent_framework-1.28.0/tests/test_csp_compose.py +288 -0
- splent_framework-1.28.0/tests/test_feature_assets.py +278 -0
- splent_framework-1.28.0/tests/test_mapper_guard.py +106 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_params_schema.py +9 -1
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u6_menu_registry.py +64 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/COPYING +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/COPYING.LESSER +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/setup.cfg +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/admin/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/admin/registry.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/app_factory.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/assets/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/audit/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/blueprints/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/blueprints/base_blueprint.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/bootstraps/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/bootstraps/locustfile_bootstrap.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/configuration/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/configuration/configuration.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/configuration/default_config.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/configuration/layers.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/context/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/context/context_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/db.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/decorators/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/decorators/decorators.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/environment/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/environment/host.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/fixtures/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/fixtures/fixtures.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/health/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/helpers/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/helpers/test_helpers_auth.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/hooks/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/i18n/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/i18n/text.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/keys/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/layout/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/layout/shells.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/locust/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/locust/common.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/config_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/cookie_security_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/csrf_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/db_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/error_handler_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/feature_loader.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/feature_order.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/health_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/locale_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/logging_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/migration_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/namespace_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/proxy_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/session_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/managers/task_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/markdown/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/markdown/render.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/migrations/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/migrations/feature_env.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/namespaces/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/nav/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/nav/nav_registry.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/observability/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/params/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/params/runtime.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/refinement/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/refinement/conflicts.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/refinement/facts.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/refinement/model_extender.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/refinement/parser.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/refinement/registry.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/refinement/templates.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/refinement/validator.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/repositories/BaseRepository.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/repositories/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/rich_text/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/rich_text/sanitize.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/search/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/search/search_registry.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/seeders/BaseSeeder.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/seeders/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/selenium/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/selenium/common.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/services/BaseService.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/services/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/services/file_access.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/services/service_locator.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/settings/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/settings/settings_schema.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/signals/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/signals/registry.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/signals/signal_utils.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/tasks/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/tasks/backends.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/tasks/dispatch.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/tasks/registry.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/tasks/runs.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/tasks/worker.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/translations/es/LC_MESSAGES/messages.mo +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/translations/es/LC_MESSAGES/messages.po +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/translations/messages.pot +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/utils/__init__.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/utils/app_loader.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/utils/feature_utils.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/utils/form_helpers.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/utils/path_utils.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/utils/text.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/utils/uvl_resolver.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework.egg-info/dependency_links.txt +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework.egg-info/requires.txt +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework.egg-info/top_level.txt +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_app_version.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_audit.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_base_blueprint_security.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_base_repository.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_config_layers.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_config_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_config_manager_return.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_config_trace.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_context_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_cookie_samesite.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_csp_nonce.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_csrf.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_default_config.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_error_handler_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_feature_loader_imports.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_feature_manager_parse.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_feature_order.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_feature_utils.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_fixtures_reset_db.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_has_role.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_health.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_health_listeners.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_helpers_host.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_helpers_locust.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_helpers_selenium.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_i18n_text.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_keys.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_locale_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_locustfile_bootstrap.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_markdown.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_migration_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_namespace_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_observability_report.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_params_boot.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_path_utils_env_file.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_prod_cookies.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_prod_db_engine_options.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_prod_factory_integration.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_prod_max_content_length.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_prod_operator_settings.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_prod_security_headers.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_prod_static_cache.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_protected_uploads_dir.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_proxy_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_pyproject_reader.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_pyproject_reader_env.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_refinement.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_refinement_boot.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_refinement_conflicts.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_refinement_hooks.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_refinement_load_order.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_refinement_models.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_refinement_routes.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_refinement_services.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_refinement_templates.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_search_registry.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_settings_schema.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_tasks.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_tasks_rq.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_test_store.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_text.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u1_app_factory.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u1_config_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u1_csrf.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u1_error_handlers.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u1_error_page_fails.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u1_forbidden_page.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u1_logging_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u2_app_loader.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u2_path_utils.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u2_session_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u3_feature_integrator.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u3_feature_link_resolver.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u3_feature_loader.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u3_feature_sources_override.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u3_refiner_extensions.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u4_contracts_snapshot.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u4_feature_lists.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u4_feature_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u5_asset_registry.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u5_asset_shells.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u5_base_blueprint.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u5_namespace_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u6_admin_registry.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u6_jinja_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u6_markdown.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u6_nav_registry.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u6_rich_text.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u6_shells.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u6_template_hooks.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u7_i18n_text.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u7_locale_manager.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u7_settings_schema.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u8_feature_env.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u8_file_access.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u8_migration_logging.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u8_model_extender.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u8_service_refinement.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u8_signals.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u9_base_repository.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u9_base_seeder.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u9_file_access.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_u9_form_helpers.py +0 -0
- {splent_framework-1.26.0 → splent_framework-1.28.0}/tests/test_uvl_resolver.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: splent_framework
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.28.0
|
|
4
4
|
Summary: SPLENT-FRAMEWORK is a set of libraries for agile product development within SPLENT.
|
|
5
5
|
Author-email: DiversoLab <diversolab@us.es>
|
|
6
6
|
License-Expression: LGPL-3.0-or-later
|
|
@@ -102,6 +102,7 @@ again after the features load.
|
|
|
102
102
|
| `SPLENT_HSTS_INCLUDE_SUBDOMAINS`, `SPLENT_HSTS_PRELOAD` | `false` | The optional HSTS directives. |
|
|
103
103
|
| `SPLENT_CONTENT_SECURITY_POLICY` | none | A Content-Security-Policy to send. Opt in, since existing templates use inline scripts. |
|
|
104
104
|
| `SPLENT_CSP_REPORT_ONLY` | `false` | Send that policy as `Content-Security-Policy-Report-Only` to try it first. |
|
|
105
|
+
| `SPLENT_CSP` | `auto` | Without a policy written above, every HTML page gets one composed from the features it drew, with the request's nonce, as `Content-Security-Policy-Report-Only`. `auto` turns it on when the product has a `[tool.splent.csp]` table, where it approves what its features ask to add; `report-only` turns it on anyway, `off` sends nothing. Enforcing it comes later. |
|
|
105
106
|
| `SPLENT_ASSET_MAX_AGE` | `31536000` | How long a versioned asset (`?v=<mtime>`) may be cached. `0` turns it off. |
|
|
106
107
|
| `SPLENT_ASSET_VERSIONING` | `true` | Add `?v=<mtime>` to the asset URLs `url_for` builds. |
|
|
107
108
|
|
|
@@ -62,6 +62,7 @@ again after the features load.
|
|
|
62
62
|
| `SPLENT_HSTS_INCLUDE_SUBDOMAINS`, `SPLENT_HSTS_PRELOAD` | `false` | The optional HSTS directives. |
|
|
63
63
|
| `SPLENT_CONTENT_SECURITY_POLICY` | none | A Content-Security-Policy to send. Opt in, since existing templates use inline scripts. |
|
|
64
64
|
| `SPLENT_CSP_REPORT_ONLY` | `false` | Send that policy as `Content-Security-Policy-Report-Only` to try it first. |
|
|
65
|
+
| `SPLENT_CSP` | `auto` | Without a policy written above, every HTML page gets one composed from the features it drew, with the request's nonce, as `Content-Security-Policy-Report-Only`. `auto` turns it on when the product has a `[tool.splent.csp]` table, where it approves what its features ask to add; `report-only` turns it on anyway, `off` sends nothing. Enforcing it comes later. |
|
|
65
66
|
| `SPLENT_ASSET_MAX_AGE` | `31536000` | How long a versioned asset (`?v=<mtime>`) may be cached. `0` turns it off. |
|
|
66
67
|
| `SPLENT_ASSET_VERSIONING` | `true` | Add `?v=<mtime>` to the asset URLs `url_for` builds. |
|
|
67
68
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "splent_framework"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.28.0"
|
|
8
8
|
description = "SPLENT-FRAMEWORK is a set of libraries for agile product development within SPLENT."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.13"
|
{splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/assets/asset_registry.py
RENAMED
|
@@ -19,16 +19,46 @@
|
|
|
19
19
|
# default, and a shell that asks for its assets without naming itself gets
|
|
20
20
|
# exactly what the public shell always got.
|
|
21
21
|
|
|
22
|
+
#
|
|
23
|
+
# An asset is global (every page of its shell, as always) or scoped to its
|
|
24
|
+
# blueprint: a library whose stylesheet styles global class names belongs
|
|
25
|
+
# only on the pages of the feature that uses it. A bundle the SPLENT
|
|
26
|
+
# toolchain built (subfolder="dist") takes its type, its integrity and its
|
|
27
|
+
# version from the feature's assets/meta/manifest.json.
|
|
28
|
+
|
|
22
29
|
#: The shells an asset can be registered for. "both" serves either shell.
|
|
23
30
|
ASSET_SHELLS = ("public", "app", "both")
|
|
24
31
|
#: The shells that render pages and ask for their assets.
|
|
25
32
|
RENDERING_SHELLS = ("public", "app")
|
|
33
|
+
#: Where an asset loads: every page of its shell, or its blueprint's pages.
|
|
34
|
+
ASSET_SCOPES = ("global", "blueprint")
|
|
35
|
+
#: How a script loads.
|
|
36
|
+
SCRIPT_TYPES = ("classic", "module")
|
|
26
37
|
|
|
27
38
|
_assets: list = []
|
|
28
39
|
|
|
29
40
|
|
|
41
|
+
class Asset(str):
|
|
42
|
+
"""An asset's URL, as get_assets returns it, which still reads as the
|
|
43
|
+
plain string it always was. ``type`` is "classic" or "module" for a
|
|
44
|
+
script, ``integrity`` its ``sha384-…`` when a production build says it,
|
|
45
|
+
and ``feature`` the blueprint that serves it."""
|
|
46
|
+
|
|
47
|
+
type: str | None = None
|
|
48
|
+
integrity: str | None = None
|
|
49
|
+
feature: str | None = None
|
|
50
|
+
|
|
51
|
+
|
|
30
52
|
def register_asset(
|
|
31
|
-
kind: str,
|
|
53
|
+
kind: str,
|
|
54
|
+
endpoint: str,
|
|
55
|
+
order: int = 100,
|
|
56
|
+
*,
|
|
57
|
+
shell: str = "public",
|
|
58
|
+
scope: str = "global",
|
|
59
|
+
type: str | None = None,
|
|
60
|
+
integrity: str | None = None,
|
|
61
|
+
**params,
|
|
32
62
|
) -> None:
|
|
33
63
|
"""Declare a static asset served by a feature blueprint's asset route.
|
|
34
64
|
|
|
@@ -40,11 +70,19 @@ def register_asset(
|
|
|
40
70
|
shell: the shell that loads it, "public" (the default), "app" or
|
|
41
71
|
"both". Keyword only, so it can never be read as a url_for
|
|
42
72
|
argument.
|
|
73
|
+
scope: "global" (the default), every page of its shell, or
|
|
74
|
+
"blueprint", only the pages the endpoint's blueprint serves.
|
|
75
|
+
type: "classic" or "module", for a script. Unset, a bundle takes it
|
|
76
|
+
from its feature's manifest, and anything else is classic.
|
|
77
|
+
integrity: the ``sha384-…`` the browser checks the file against.
|
|
78
|
+
Unset, a bundle of a production build takes it from its
|
|
79
|
+
feature's manifest.
|
|
43
80
|
**params: url_for params for the asset route, e.g.
|
|
44
81
|
subfolder="css", filename="slider.css".
|
|
45
82
|
|
|
46
83
|
Raises:
|
|
47
|
-
ValueError: when ``shell`` is not one of
|
|
84
|
+
ValueError: when ``shell``, ``scope`` or ``type`` is not one of
|
|
85
|
+
:data:`ASSET_SHELLS`, :data:`ASSET_SCOPES` or :data:`SCRIPT_TYPES`.
|
|
48
86
|
|
|
49
87
|
Registering the same asset again keeps the first registration. When the
|
|
50
88
|
second one names the other shell, the asset serves both, so a skin that
|
|
@@ -58,6 +96,16 @@ def register_asset(
|
|
|
58
96
|
f"register_asset({kind!r}, {endpoint!r}): shell must be 'public', "
|
|
59
97
|
f"'app' or 'both', not {shell!r}"
|
|
60
98
|
)
|
|
99
|
+
if scope not in ASSET_SCOPES:
|
|
100
|
+
raise ValueError(
|
|
101
|
+
f"register_asset({kind!r}, {endpoint!r}): scope must be 'global' or "
|
|
102
|
+
f"'blueprint', not {scope!r}"
|
|
103
|
+
)
|
|
104
|
+
if type is not None and type not in SCRIPT_TYPES:
|
|
105
|
+
raise ValueError(
|
|
106
|
+
f"register_asset({kind!r}, {endpoint!r}): type must be 'classic' or "
|
|
107
|
+
f"'module', not {type!r}"
|
|
108
|
+
)
|
|
61
109
|
key = (kind, endpoint, tuple(sorted(params.items())))
|
|
62
110
|
for a in _assets:
|
|
63
111
|
if a["key"] == key:
|
|
@@ -72,6 +120,9 @@ def register_asset(
|
|
|
72
120
|
"params": params,
|
|
73
121
|
"order": order,
|
|
74
122
|
"shell": shell,
|
|
123
|
+
"scope": scope,
|
|
124
|
+
"type": type,
|
|
125
|
+
"integrity": integrity,
|
|
75
126
|
}
|
|
76
127
|
)
|
|
77
128
|
|
|
@@ -90,13 +141,16 @@ def get_assets(kind: str, *, shell: str = "public") -> list:
|
|
|
90
141
|
Raises:
|
|
91
142
|
ValueError: when ``shell`` is not one of :data:`RENDERING_SHELLS`.
|
|
92
143
|
"""
|
|
93
|
-
from flask import url_for
|
|
144
|
+
from flask import has_request_context, request, url_for
|
|
145
|
+
|
|
146
|
+
from splent_framework.assets import feature_assets
|
|
94
147
|
|
|
95
148
|
if shell not in RENDERING_SHELLS:
|
|
96
149
|
raise ValueError(
|
|
97
150
|
f"get_assets({kind!r}): shell must be 'public' or 'app', the shell "
|
|
98
151
|
f"rendering the page, not {shell!r}"
|
|
99
152
|
)
|
|
153
|
+
blueprint = request.blueprint if has_request_context() else None
|
|
100
154
|
seen = set()
|
|
101
155
|
out = []
|
|
102
156
|
for a in sorted(_assets, key=lambda x: (x["order"], x["endpoint"])):
|
|
@@ -104,8 +158,20 @@ def get_assets(kind: str, *, shell: str = "public") -> list:
|
|
|
104
158
|
continue
|
|
105
159
|
if a.get("shell", "public") not in (shell, "both"):
|
|
106
160
|
continue
|
|
161
|
+
feature = a["endpoint"].rsplit(".", 1)[0]
|
|
162
|
+
if a.get("scope") == "blueprint" and feature != blueprint:
|
|
163
|
+
continue
|
|
164
|
+
manifest = filename = None
|
|
165
|
+
params = dict(a["params"])
|
|
166
|
+
if params.get("subfolder") == "dist" and "v" not in params:
|
|
167
|
+
# A bundle's version is its content hash, as feature_script's.
|
|
168
|
+
manifest = feature_assets.manifest_of(feature)
|
|
169
|
+
filename = params.get("filename") or ""
|
|
170
|
+
version = feature_assets.content_version(manifest, filename)
|
|
171
|
+
if version:
|
|
172
|
+
params["v"] = version
|
|
107
173
|
try:
|
|
108
|
-
href = url_for(a["endpoint"], **
|
|
174
|
+
href = url_for(a["endpoint"], **params)
|
|
109
175
|
except Exception:
|
|
110
176
|
continue
|
|
111
177
|
# Cache-bust by the asset file's modification time: the asset route
|
|
@@ -121,10 +187,52 @@ def get_assets(kind: str, *, shell: str = "public") -> list:
|
|
|
121
187
|
href = f"{href}{separator}v={version}"
|
|
122
188
|
if href not in seen:
|
|
123
189
|
seen.add(href)
|
|
124
|
-
|
|
190
|
+
asset = Asset(href)
|
|
191
|
+
asset.feature = feature
|
|
192
|
+
asset.integrity = a.get("integrity") or feature_assets.integrity(
|
|
193
|
+
manifest, filename or ""
|
|
194
|
+
)
|
|
195
|
+
if kind == "js":
|
|
196
|
+
asset.type = (
|
|
197
|
+
a.get("type")
|
|
198
|
+
or feature_assets.entry_type(manifest, filename or "")
|
|
199
|
+
or "classic"
|
|
200
|
+
)
|
|
201
|
+
feature_assets.mark_painted(feature)
|
|
202
|
+
out.append(asset)
|
|
125
203
|
return out
|
|
126
204
|
|
|
127
205
|
|
|
206
|
+
def render_assets(kind: str, *, shell: str = "public"):
|
|
207
|
+
"""The tags of get_assets(KIND, shell=SHELL), with what each needs: a
|
|
208
|
+
stylesheet's ``<link>``; a script's ``<script>``, deferred, or of type
|
|
209
|
+
module; the integrity of a production bundle; the request's CSP nonce.
|
|
210
|
+
A shell writes ``{{ render_assets('js', shell='app') }}`` instead of
|
|
211
|
+
looping over get_assets."""
|
|
212
|
+
from markupsafe import Markup, escape
|
|
213
|
+
|
|
214
|
+
from splent_framework.managers.security_headers_manager import csp_nonce
|
|
215
|
+
|
|
216
|
+
nonce = escape(csp_nonce())
|
|
217
|
+
tags = []
|
|
218
|
+
for asset in get_assets(kind, shell=shell):
|
|
219
|
+
checked = f' integrity="{escape(asset.integrity)}"' if asset.integrity else ""
|
|
220
|
+
if kind == "css":
|
|
221
|
+
tags.append(
|
|
222
|
+
f'<link rel="stylesheet" href="{escape(asset)}"{checked} nonce="{nonce}">'
|
|
223
|
+
)
|
|
224
|
+
elif asset.type == "module":
|
|
225
|
+
tags.append(
|
|
226
|
+
f'<script type="module" src="{escape(asset)}"{checked} '
|
|
227
|
+
f'nonce="{nonce}"></script>'
|
|
228
|
+
)
|
|
229
|
+
else:
|
|
230
|
+
tags.append(
|
|
231
|
+
f'<script src="{escape(asset)}" defer{checked} nonce="{nonce}"></script>'
|
|
232
|
+
)
|
|
233
|
+
return Markup("\n".join(tags))
|
|
234
|
+
|
|
235
|
+
|
|
128
236
|
def _asset_version(endpoint, params):
|
|
129
237
|
"""Modification time of the asset file behind a route, or None. Resolved
|
|
130
238
|
through the blueprint that owns the route, the same way the asset route
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
# splent_framework/assets/feature_assets.py
|
|
2
|
+
"""A feature's bundles, drawn from the manifest its build wrote (SD-01).
|
|
3
|
+
|
|
4
|
+
A feature with ``frontend/`` builds in the SPLENT toolchain, which writes
|
|
5
|
+
``assets/meta/manifest.json`` beside the bundles in ``assets/dist``: each
|
|
6
|
+
entry with its files and its type (a classic script or a module), each file
|
|
7
|
+
with its sha256 and, in a production build, its sha384. A template draws an
|
|
8
|
+
entry with ``feature_script`` and ``feature_style`` instead of writing the
|
|
9
|
+
tags itself, and gets:
|
|
10
|
+
|
|
11
|
+
* the URL with ``?v=`` the file's content hash, the same on every replica
|
|
12
|
+
and every install of one wheel, so the asset route caches it for good;
|
|
13
|
+
* ``integrity`` (SRI) when the build is a production one, so the browser
|
|
14
|
+
runs exactly the bytes the release built;
|
|
15
|
+
* the request's CSP nonce, and ``defer`` (a module is deferred already), so
|
|
16
|
+
scripts run in the order of the document once it is parsed;
|
|
17
|
+
* the bundles of the features it consumes an API from (``splent.consumes``)
|
|
18
|
+
first, once per response, so a provider runs before its consumers;
|
|
19
|
+
* ``window.SPLENT.ready(feature)``, a promise that settles once every
|
|
20
|
+
bundle of that feature drawn on the page has run, for code that cannot
|
|
21
|
+
wait in document order (``SPLENT.ready("uploads").then(...)``).
|
|
22
|
+
|
|
23
|
+
A feature without a manifest (a legacy build, or one never built) gets the
|
|
24
|
+
tag it had before: ``<feature>/dist/<entry>.bundle.js`` with ``?v=`` its
|
|
25
|
+
modification time and no integrity.
|
|
26
|
+
|
|
27
|
+
Every feature drawn in a response is noted, by these helpers, the asset
|
|
28
|
+
registry and the template hooks, and the view's own: that list is what the
|
|
29
|
+
response's Content-Security-Policy is composed from (managers/csp.py).
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
import json
|
|
33
|
+
import logging
|
|
34
|
+
import os
|
|
35
|
+
|
|
36
|
+
from flask import current_app, g, has_request_context, request, url_for
|
|
37
|
+
from markupsafe import Markup, escape
|
|
38
|
+
|
|
39
|
+
logger = logging.getLogger(__name__)
|
|
40
|
+
|
|
41
|
+
FEATURE_PREFIX = "splent_feature_"
|
|
42
|
+
MANIFEST = ("meta", "manifest.json")
|
|
43
|
+
#: How much of a file's sha256 its URL carries as ``?v=``.
|
|
44
|
+
VERSION_LENGTH = 16
|
|
45
|
+
|
|
46
|
+
_PAINTED = "_splent_painted_features"
|
|
47
|
+
_EMITTED = "_splent_emitted_entries"
|
|
48
|
+
_RUNTIME = "_splent_runtime_emitted"
|
|
49
|
+
|
|
50
|
+
# {path: (mtime, manifest)}: a manifest is read again only when its file
|
|
51
|
+
# changes, which a watch build does on every emit.
|
|
52
|
+
_cache: dict = {}
|
|
53
|
+
|
|
54
|
+
# window.SPLENT.ready: the promise of a feature settles once every script
|
|
55
|
+
# tagged data-splent-feature="<it>" has loaded. A script's load event does
|
|
56
|
+
# not bubble, so it is caught on the way down, in the capture phase.
|
|
57
|
+
RUNTIME = (
|
|
58
|
+
"(function(){var S=window.SPLENT=window.SPLENT||{};if(S.ready)return;"
|
|
59
|
+
"var w={};function slot(n){if(!w[n]){var r,p=new Promise(function(x){r=x;});"
|
|
60
|
+
"w[n]={p:p,r:r};}return w[n];}"
|
|
61
|
+
"S.ready=function(n){return slot(n).p;};"
|
|
62
|
+
'document.addEventListener("load",function(e){var t=e.target;'
|
|
63
|
+
'if(!t||t.tagName!=="SCRIPT")return;var n=t.getAttribute("data-splent-feature");'
|
|
64
|
+
'if(!n)return;t.setAttribute("data-splent-loaded","");'
|
|
65
|
+
'var all=document.querySelectorAll("script[data-splent-feature]:not([data-splent-loaded])");'
|
|
66
|
+
'for(var i=0;i<all.length;i++){if(all[i].getAttribute("data-splent-feature")===n)return;}'
|
|
67
|
+
"slot(n).r();},true);})();"
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def short_name(feature: str) -> str:
|
|
72
|
+
"""``splent_feature_uploads`` or ``uploads``: the name of its blueprint."""
|
|
73
|
+
return feature.removeprefix(FEATURE_PREFIX)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
# ── Manifests ──────────────────────────────────────────────────────────
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def manifest_path(feature: str, app=None) -> str | None:
|
|
80
|
+
"""Where the manifest of FEATURE is, through its blueprint, or None."""
|
|
81
|
+
app = app or current_app
|
|
82
|
+
blueprint = app.blueprints.get(short_name(feature))
|
|
83
|
+
resolver = getattr(blueprint, "_resolve_asset_path", None)
|
|
84
|
+
if resolver is None:
|
|
85
|
+
return None
|
|
86
|
+
path, _base = resolver(*MANIFEST)
|
|
87
|
+
return path
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def manifest_of(feature: str, app=None) -> dict | None:
|
|
91
|
+
"""The manifest FEATURE's build wrote, or None for a legacy feature."""
|
|
92
|
+
path = manifest_path(feature, app)
|
|
93
|
+
if not path:
|
|
94
|
+
return None
|
|
95
|
+
try:
|
|
96
|
+
mtime = os.path.getmtime(path)
|
|
97
|
+
except OSError:
|
|
98
|
+
return None
|
|
99
|
+
kept = _cache.get(path)
|
|
100
|
+
if kept and kept[0] == mtime:
|
|
101
|
+
return kept[1]
|
|
102
|
+
try:
|
|
103
|
+
with open(path, encoding="utf-8") as handle:
|
|
104
|
+
manifest = json.load(handle)
|
|
105
|
+
except (OSError, ValueError) as e:
|
|
106
|
+
logger.warning("%s cannot be read, so it is ignored: %s", path, e)
|
|
107
|
+
manifest = None
|
|
108
|
+
if not isinstance(manifest, dict):
|
|
109
|
+
manifest = None
|
|
110
|
+
_cache[path] = (mtime, manifest)
|
|
111
|
+
return manifest
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def content_version(manifest: dict | None, filename: str) -> str | None:
|
|
115
|
+
"""The ``?v=`` of FILENAME in assets/dist: the start of its sha256."""
|
|
116
|
+
entry = ((manifest or {}).get("files") or {}).get(filename) or {}
|
|
117
|
+
sha256 = entry.get("sha256")
|
|
118
|
+
return sha256[:VERSION_LENGTH] if isinstance(sha256, str) else None
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def integrity(manifest: dict | None, filename: str) -> str | None:
|
|
122
|
+
"""``sha384-<digest>`` of FILENAME, only from a production build."""
|
|
123
|
+
if not manifest or manifest.get("mode") != "production":
|
|
124
|
+
return None
|
|
125
|
+
entry = (manifest.get("files") or {}).get(filename) or {}
|
|
126
|
+
digest = entry.get("sha384")
|
|
127
|
+
return f"sha384-{digest}" if isinstance(digest, str) and digest else None
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def entry_type(manifest: dict | None, filename: str) -> str | None:
|
|
131
|
+
"""``classic`` or ``module``: the type of the entry FILENAME belongs to."""
|
|
132
|
+
for entry in ((manifest or {}).get("entries") or {}).values():
|
|
133
|
+
if filename in (entry.get("js") or []):
|
|
134
|
+
return entry.get("type") or "classic"
|
|
135
|
+
return None
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def dist_version(endpoint: str, values: dict, app=None) -> str | None:
|
|
139
|
+
"""The content version of the assets/dist file a ``<feature>.assets``
|
|
140
|
+
URL names, which the static cache accepts as well as the mtime."""
|
|
141
|
+
if not endpoint or not endpoint.endswith(".assets"):
|
|
142
|
+
return None
|
|
143
|
+
if (values or {}).get("subfolder") != "dist":
|
|
144
|
+
return None
|
|
145
|
+
manifest = manifest_of(endpoint.rsplit(".", 1)[0], app)
|
|
146
|
+
return content_version(manifest, (values or {}).get("filename") or "")
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
# ── What a response draws ──────────────────────────────────────────────
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def _owned(attr: str, factory):
|
|
153
|
+
"""A per-request value of ``g``, which remembers the request it was made
|
|
154
|
+
for: a test that keeps one app context serves several requests in it."""
|
|
155
|
+
owner = request._get_current_object() if has_request_context() else None
|
|
156
|
+
kept = g.get(attr)
|
|
157
|
+
if kept is not None and kept[0] is owner:
|
|
158
|
+
return kept[1]
|
|
159
|
+
value = factory()
|
|
160
|
+
setattr(g, attr, (owner, value))
|
|
161
|
+
return value
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def mark_painted(feature: str | None) -> None:
|
|
165
|
+
"""Note that FEATURE drew something in the response being rendered."""
|
|
166
|
+
if not feature or not has_request_context():
|
|
167
|
+
return
|
|
168
|
+
painted = _owned(_PAINTED, list)
|
|
169
|
+
name = short_name(feature)
|
|
170
|
+
if name not in painted:
|
|
171
|
+
painted.append(name)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def painted_features() -> list[str]:
|
|
175
|
+
"""The features drawn in this response, by blueprint name: the ones
|
|
176
|
+
noted, and the one whose view serves it."""
|
|
177
|
+
if not has_request_context():
|
|
178
|
+
return []
|
|
179
|
+
painted = list(_owned(_PAINTED, list))
|
|
180
|
+
if request.blueprint and request.blueprint not in painted:
|
|
181
|
+
painted.insert(0, request.blueprint)
|
|
182
|
+
return painted
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def _entry_name(feature: str, manifest: dict, entry: str | None) -> str:
|
|
186
|
+
entries = manifest.get("entries") or {}
|
|
187
|
+
if entry is not None:
|
|
188
|
+
if entry not in entries:
|
|
189
|
+
raise ValueError(
|
|
190
|
+
f"{short_name(feature)} has no entry {entry!r}: its build has "
|
|
191
|
+
f"{', '.join(sorted(entries)) or 'none'}."
|
|
192
|
+
)
|
|
193
|
+
return entry
|
|
194
|
+
if short_name(feature) in entries:
|
|
195
|
+
return short_name(feature)
|
|
196
|
+
if len(entries) == 1:
|
|
197
|
+
return next(iter(entries))
|
|
198
|
+
raise ValueError(
|
|
199
|
+
f"{short_name(feature)} builds {', '.join(sorted(entries)) or 'no entry'}: "
|
|
200
|
+
"name the one to draw, feature_script(feature, entry)."
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def _attributes(**attrs) -> str:
|
|
205
|
+
parts = []
|
|
206
|
+
for name, value in attrs.items():
|
|
207
|
+
name = name.rstrip("_").replace("_", "-")
|
|
208
|
+
if value is True:
|
|
209
|
+
parts.append(f" {name}")
|
|
210
|
+
elif value:
|
|
211
|
+
parts.append(f' {name}="{escape(value)}"')
|
|
212
|
+
return "".join(parts)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def _url(feature: str, filename: str, version: str | None) -> str:
|
|
216
|
+
values = {"subfolder": "dist", "filename": filename}
|
|
217
|
+
if version:
|
|
218
|
+
values["v"] = version
|
|
219
|
+
return url_for(f"{short_name(feature)}.assets", **values)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def _nonce() -> str:
|
|
223
|
+
from splent_framework.managers.security_headers_manager import csp_nonce
|
|
224
|
+
|
|
225
|
+
return csp_nonce()
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def _runtime_tag() -> str:
|
|
229
|
+
"""The SPLENT.ready runtime, once per response, before the first script."""
|
|
230
|
+
drawn = _owned(_RUNTIME, lambda: [False])
|
|
231
|
+
if drawn[0]:
|
|
232
|
+
return ""
|
|
233
|
+
drawn[0] = True
|
|
234
|
+
return f'<script nonce="{escape(_nonce())}">{RUNTIME}</script>\n'
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def _script_tags(feature: str, entry: str | None, defer: bool, seen: set) -> list:
|
|
238
|
+
name = short_name(feature)
|
|
239
|
+
if name not in current_app.blueprints:
|
|
240
|
+
# A feature the product does not have draws nothing: a template may
|
|
241
|
+
# name an optional one.
|
|
242
|
+
return []
|
|
243
|
+
manifest = manifest_of(name)
|
|
244
|
+
if manifest is None:
|
|
245
|
+
key = (name, entry or name)
|
|
246
|
+
emitted = _owned(_EMITTED, set)
|
|
247
|
+
if key in emitted:
|
|
248
|
+
return []
|
|
249
|
+
emitted.add(key)
|
|
250
|
+
mark_painted(name)
|
|
251
|
+
src = url_for(
|
|
252
|
+
f"{name}.assets", subfolder="dist", filename=f"{entry or name}.bundle.js"
|
|
253
|
+
)
|
|
254
|
+
return [
|
|
255
|
+
f"<script{_attributes(src=src, defer=defer, nonce=_nonce())}"
|
|
256
|
+
f' data-splent-feature="{escape(name)}"></script>'
|
|
257
|
+
]
|
|
258
|
+
entry = _entry_name(name, manifest, entry)
|
|
259
|
+
key = (name, entry)
|
|
260
|
+
emitted = _owned(_EMITTED, set)
|
|
261
|
+
if key in emitted or key in seen:
|
|
262
|
+
return []
|
|
263
|
+
seen.add(key)
|
|
264
|
+
tags = []
|
|
265
|
+
# The providers of what this entry consumes run first.
|
|
266
|
+
for wanted in (manifest.get("consumes") or {}).values():
|
|
267
|
+
provider = (wanted or {}).get("feature") if isinstance(wanted, dict) else None
|
|
268
|
+
if provider and short_name(provider) != name:
|
|
269
|
+
tags += _script_tags(provider, None, defer, seen)
|
|
270
|
+
emitted.add(key)
|
|
271
|
+
mark_painted(name)
|
|
272
|
+
described = (manifest.get("entries") or {}).get(entry) or {}
|
|
273
|
+
module = described.get("type") == "module"
|
|
274
|
+
for filename in described.get("js") or []:
|
|
275
|
+
attrs = {
|
|
276
|
+
"type": "module" if module else None,
|
|
277
|
+
"src": _url(name, filename, content_version(manifest, filename)),
|
|
278
|
+
"defer": defer and not module,
|
|
279
|
+
"integrity": integrity(manifest, filename),
|
|
280
|
+
"nonce": _nonce(),
|
|
281
|
+
}
|
|
282
|
+
tags.append(
|
|
283
|
+
f"<script{_attributes(**attrs)}"
|
|
284
|
+
f' data-splent-feature="{escape(name)}"></script>'
|
|
285
|
+
)
|
|
286
|
+
return tags
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def feature_script(feature: str, entry: str | None = None, *, defer: bool = True):
|
|
290
|
+
"""The ``<script>`` tags of FEATURE's ENTRY, providers first.
|
|
291
|
+
|
|
292
|
+
ENTRY defaults to the one named after the feature, or the only one. A
|
|
293
|
+
classic entry is ``defer``; ``defer=False`` keeps a blocking script for
|
|
294
|
+
a page whose inline code still calls the bundle while the page parses.
|
|
295
|
+
Drawing an entry already drawn in this response draws nothing, and so
|
|
296
|
+
does a feature the product does not have.
|
|
297
|
+
"""
|
|
298
|
+
tags = _script_tags(feature, entry, defer, set())
|
|
299
|
+
if not tags:
|
|
300
|
+
return Markup("")
|
|
301
|
+
return Markup(_runtime_tag() + "\n".join(tags))
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
def feature_style(feature: str, entry: str | None = None):
|
|
305
|
+
"""The ``<link rel="stylesheet">`` of FEATURE's ENTRY, from its build.
|
|
306
|
+
|
|
307
|
+
A legacy feature, or an entry whose build wrote no stylesheet, draws
|
|
308
|
+
nothing: their stylesheets live in assets/css, as before.
|
|
309
|
+
"""
|
|
310
|
+
name = short_name(feature)
|
|
311
|
+
if name not in current_app.blueprints:
|
|
312
|
+
return Markup("")
|
|
313
|
+
manifest = manifest_of(name)
|
|
314
|
+
if manifest is None:
|
|
315
|
+
return Markup("")
|
|
316
|
+
entry = _entry_name(name, manifest, entry)
|
|
317
|
+
mark_painted(name)
|
|
318
|
+
links = []
|
|
319
|
+
for filename in ((manifest.get("entries") or {}).get(entry) or {}).get("css") or []:
|
|
320
|
+
attrs = {
|
|
321
|
+
"rel": "stylesheet",
|
|
322
|
+
"href": _url(name, filename, content_version(manifest, filename)),
|
|
323
|
+
"integrity": integrity(manifest, filename),
|
|
324
|
+
"nonce": _nonce(),
|
|
325
|
+
}
|
|
326
|
+
links.append(f"<link{_attributes(**attrs)}>")
|
|
327
|
+
return Markup("\n".join(links))
|
{splent_framework-1.26.0 → splent_framework-1.28.0}/src/splent_framework/hooks/template_hooks.py
RENAMED
|
@@ -129,8 +129,16 @@ def remove_template_hook(name: str, func) -> None:
|
|
|
129
129
|
|
|
130
130
|
|
|
131
131
|
def get_template_hooks(name: str) -> list:
|
|
132
|
-
"""Callbacks for a slot, ordered by their registration `order`.
|
|
133
|
-
|
|
132
|
+
"""Callbacks for a slot, ordered by their registration `order`.
|
|
133
|
+
|
|
134
|
+
In a request, the features that own them count as drawn in the page,
|
|
135
|
+
for its Content-Security-Policy (managers/csp.py): the template calls
|
|
136
|
+
every callback it gets.
|
|
137
|
+
"""
|
|
138
|
+
entries = sorted(_hooks.get(name, []), key=_sort_key)
|
|
139
|
+
for entry in entries:
|
|
140
|
+
_painted(entry)
|
|
141
|
+
return [entry[1] for entry in entries]
|
|
134
142
|
|
|
135
143
|
|
|
136
144
|
def render_template_hooks(name: str):
|
|
@@ -146,9 +154,11 @@ def render_template_hooks(name: str):
|
|
|
146
154
|
from markupsafe import Markup
|
|
147
155
|
|
|
148
156
|
parts = []
|
|
149
|
-
for
|
|
150
|
-
out =
|
|
157
|
+
for entry in sorted(_hooks.get(name, []), key=_sort_key):
|
|
158
|
+
out = entry[1]()
|
|
151
159
|
if out:
|
|
160
|
+
# Only a callback that drew something counts as drawn in the page.
|
|
161
|
+
_painted(entry)
|
|
152
162
|
parts.append(str(out))
|
|
153
163
|
return Markup("".join(parts))
|
|
154
164
|
|
|
@@ -265,6 +275,14 @@ def _undeclared_message(feature: str, name: str, base: str | None) -> str:
|
|
|
265
275
|
)
|
|
266
276
|
|
|
267
277
|
|
|
278
|
+
def _painted(entry) -> None:
|
|
279
|
+
owner = entry[2] if len(entry) > 2 else ""
|
|
280
|
+
if owner.startswith("splent_feature_"):
|
|
281
|
+
from splent_framework.assets.feature_assets import mark_painted
|
|
282
|
+
|
|
283
|
+
mark_painted(owner)
|
|
284
|
+
|
|
285
|
+
|
|
268
286
|
def _module(func) -> str:
|
|
269
287
|
"""The module of a callable, through partials and ``__wrapped__``."""
|
|
270
288
|
for _ in range(32): # a bound on wrapper chains, never reached in practice
|