streamtex 0.7.63__tar.gz → 0.7.65__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.
Files changed (190) hide show
  1. {streamtex-0.7.63/streamtex.egg-info → streamtex-0.7.65}/PKG-INFO +1 -1
  2. {streamtex-0.7.63 → streamtex-0.7.65}/pyproject.toml +1 -1
  3. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/book.py +24 -2
  4. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/export_cmd.py +32 -1
  5. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/release_cmd.py +67 -19
  6. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/deploy/stx_auth.py +1 -1
  7. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/export_widgets.py +221 -14
  8. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/image.py +3 -1
  9. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/__init__.py +2 -1
  10. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/build.py +28 -7
  11. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/ops.py +123 -21
  12. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/state.py +6 -2
  13. {streamtex-0.7.63 → streamtex-0.7.65/streamtex.egg-info}/PKG-INFO +1 -1
  14. {streamtex-0.7.63 → streamtex-0.7.65}/LICENSE +0 -0
  15. {streamtex-0.7.63 → streamtex-0.7.65}/MANIFEST.in +0 -0
  16. {streamtex-0.7.63 → streamtex-0.7.65}/README.md +0 -0
  17. {streamtex-0.7.63 → streamtex-0.7.65}/setup.cfg +0 -0
  18. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/__init__.py +0 -0
  19. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/__main__.py +0 -0
  20. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/ai/__init__.py +0 -0
  21. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/ai/config.py +0 -0
  22. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/ai/generate.py +0 -0
  23. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/ai/history.py +0 -0
  24. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/ai/metadata.py +0 -0
  25. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/ai/providers/__init__.py +0 -0
  26. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/ai/providers/base.py +0 -0
  27. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/ai/providers/fal.py +0 -0
  28. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/ai/providers/google.py +0 -0
  29. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/ai/providers/openai.py +0 -0
  30. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/ai/providers/registry.py +0 -0
  31. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/auth.py +0 -0
  32. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/banner.py +0 -0
  33. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/bib.py +0 -0
  34. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/bib_preview.py +0 -0
  35. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/block_helpers.py +0 -0
  36. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/blocks.py +0 -0
  37. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/browser.py +0 -0
  38. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/__init__.py +0 -0
  39. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/_claude_files.py +0 -0
  40. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/_divergence.py +0 -0
  41. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/_install_local_packs.py +0 -0
  42. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/_shared.py +0 -0
  43. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/_stx_toml.py +0 -0
  44. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/_toml_helpers.py +0 -0
  45. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/artifact_cmd.py +0 -0
  46. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/bib_cmd.py +0 -0
  47. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/build_check.py +0 -0
  48. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/cache_cmd.py +0 -0
  49. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/claude_cmd.py +0 -0
  50. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/claude_global.py +0 -0
  51. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/claude_project.py +0 -0
  52. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/commands.py +0 -0
  53. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/component_cmd.py +0 -0
  54. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/console.py +0 -0
  55. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/coolify.py +0 -0
  56. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/deploy_auth_cmd.py +0 -0
  57. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/deploy_cmd.py +0 -0
  58. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/dev_cmd.py +0 -0
  59. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/dev_config.py +0 -0
  60. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/ds_cmd.py +0 -0
  61. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/install_cmd.py +0 -0
  62. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/kit_cmd.py +0 -0
  63. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/main.py +0 -0
  64. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/migrations/__init__.py +0 -0
  65. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/migrations/base.py +0 -0
  66. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/migrations/compat.py +0 -0
  67. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/migrations/registry.py +0 -0
  68. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/migrations/v0_4_0.py +0 -0
  69. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/migrations/v0_4_6.py +0 -0
  70. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/pack_cmd.py +0 -0
  71. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/project_cmd.py +0 -0
  72. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/project_rules.py +0 -0
  73. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/publish_cmd.py +0 -0
  74. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/published_check.py +0 -0
  75. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/run_cmd.py +0 -0
  76. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/run_set.py +0 -0
  77. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/screenshot_cmd.py +0 -0
  78. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/shortcuts.py +0 -0
  79. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/status_cmd.py +0 -0
  80. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/sync_cmd.py +0 -0
  81. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/upgrade_cmd.py +0 -0
  82. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/validate_cmd.py +0 -0
  83. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/cli/workspace_cmd.py +0 -0
  84. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/code.py +0 -0
  85. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/collection.py +0 -0
  86. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/constants.py +0 -0
  87. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/container.py +0 -0
  88. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/__init__.py +0 -0
  89. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/artifacts/__init__.py +0 -0
  90. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/artifacts/_frontmatter.py +0 -0
  91. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/artifacts/agent.py +0 -0
  92. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/artifacts/ai_prompt.py +0 -0
  93. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/artifacts/archetype.py +0 -0
  94. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/artifacts/asset.py +0 -0
  95. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/artifacts/discovery.py +0 -0
  96. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/artifacts/guideline.py +0 -0
  97. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/artifacts/install.py +0 -0
  98. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/artifacts/integration.py +0 -0
  99. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/artifacts/loaders.py +0 -0
  100. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/artifacts/palette.py +0 -0
  101. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/artifacts/skill.py +0 -0
  102. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/artifacts/spec.py +0 -0
  103. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/artifacts/validation.py +0 -0
  104. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/contracts.py +0 -0
  105. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/discovery.py +0 -0
  106. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/core/validation.py +0 -0
  107. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/countdown.py +0 -0
  108. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/deeplink.py +0 -0
  109. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/deploy/__init__.py +0 -0
  110. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/enums.py +0 -0
  111. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/export.py +0 -0
  112. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/export_enrich.py +0 -0
  113. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/export_paginate.py +0 -0
  114. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/facts.py +0 -0
  115. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/grid.py +0 -0
  116. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/gsheet.py +0 -0
  117. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/hover_tooltip.py +0 -0
  118. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/i18n.py +0 -0
  119. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/image_crop.py +0 -0
  120. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/image_editor.py +0 -0
  121. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/image_utils.py +0 -0
  122. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/inspector.py +0 -0
  123. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/kept.py +0 -0
  124. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/latex.py +0 -0
  125. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/latex_utils.py +0 -0
  126. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/link_config.py +0 -0
  127. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/link_preview.py +0 -0
  128. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/list.py +0 -0
  129. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/loading.py +0 -0
  130. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/markdown.py +0 -0
  131. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/marker.py +0 -0
  132. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/marker_runtime.py +0 -0
  133. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/media_overlay.py +0 -0
  134. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/mermaid.py +0 -0
  135. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/overlay.py +0 -0
  136. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/pagewalk.py +0 -0
  137. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/pdf_export.py +0 -0
  138. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/plantuml.py +0 -0
  139. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/presentation.py +0 -0
  140. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/presentation_profile.py +0 -0
  141. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/printing.py +0 -0
  142. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/config.py +0 -0
  143. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/coolify.py +0 -0
  144. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/passwords.py +0 -0
  145. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/target.py +0 -0
  146. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/templates/live/Dockerfile +0 -0
  147. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/templates/live/entrypoint.sh +0 -0
  148. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/templates/live/nginx.conf +0 -0
  149. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/templates/live/stx-http.conf +0 -0
  150. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/templates/live/supervisord.conf +0 -0
  151. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/templates/static/10-stx-init.sh +0 -0
  152. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/templates/static/20-stx-auth.sh +0 -0
  153. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/templates/static/Dockerfile +0 -0
  154. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/templates/static/nginx.conf +0 -0
  155. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/templates/static/stx-http.conf +0 -0
  156. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/release/templates/static/stx_auth.py +0 -0
  157. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/runtime_flags.py +0 -0
  158. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/scripts/__init__.py +0 -0
  159. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/scripts/migrate_curves_to_relative.py +0 -0
  160. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/search.py +0 -0
  161. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/slide.py +0 -0
  162. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/space.py +0 -0
  163. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/spacing.py +0 -0
  164. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/static/css/stx_global.css +0 -0
  165. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/static/default.css +0 -0
  166. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/static/js/stx_countdown.js +0 -0
  167. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/static/js/stx_marker_observer.js +0 -0
  168. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/static/js/stx_scroll_spy.js +0 -0
  169. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/static/js/stx_video.js +0 -0
  170. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/static/logo-stx-tiny.png +0 -0
  171. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/static/logo-stx.png +0 -0
  172. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/styles/__init__.py +0 -0
  173. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/styles/base.py +0 -0
  174. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/styles/container.py +0 -0
  175. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/styles/core.py +0 -0
  176. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/styles/scale.py +0 -0
  177. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/styles/scale_curves.toml +0 -0
  178. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/styles/text.py +0 -0
  179. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/styles/visibility.py +0 -0
  180. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/tikz.py +0 -0
  181. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/toc.py +0 -0
  182. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/utils.py +0 -0
  183. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/watch.py +0 -0
  184. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/write.py +0 -0
  185. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex/zoom.py +0 -0
  186. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex.egg-info/SOURCES.txt +0 -0
  187. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex.egg-info/dependency_links.txt +0 -0
  188. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex.egg-info/entry_points.txt +0 -0
  189. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex.egg-info/requires.txt +0 -0
  190. {streamtex-0.7.63 → streamtex-0.7.65}/streamtex.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streamtex
3
- Version: 0.7.63
3
+ Version: 0.7.65
4
4
  Summary: AI-powered content framework for Streamlit — create presentations, courses, and web-books with Claude or Cursor, no coding required.
5
5
  Author-email: Nicolas Guelfi <nicolas.guelfi@laposte.net>
6
6
  License-Expression: BUSL-1.1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "streamtex"
7
- version = "0.7.63"
7
+ version = "0.7.65"
8
8
  description = "AI-powered content framework for Streamlit — create presentations, courses, and web-books with Claude or Cursor, no coding required."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -108,6 +108,14 @@ _export_page_sentinels = False
108
108
  #: The HTML export mode the module asks for: "continuous", "paginated" or
109
109
  #: "both" (#106) — set by st_book, read by ``stx export html``.
110
110
  _html_export_mode = "continuous"
111
+
112
+ #: ``stx export html --up-to-slide N`` (#146): the build stops after the entry
113
+ #: that holds the N-th stop (the slide counter's N); later entries never run,
114
+ #: so nothing of them reaches the export. The build then records what it kept
115
+ #: in ``_warmup_limit_result``: ``{"up_to_slide", "last_slide", "entries",
116
+ #: "stops"}`` (``stops``: the stops of the kept entries).
117
+ _warmup_up_to_slide: int | None = None
118
+ _warmup_limit_result: dict | None = None
111
119
  HTML_EXPORT_MODES = ("continuous", "paginated", "both")
112
120
 
113
121
  # Optional ExportConfig for headless export — set by CLI ``stx export html``.
@@ -2591,6 +2599,8 @@ def _build_page_cache(module_list, toc_config, marker_config, separator,
2591
2599
  # call returns, so the buffer is preserved regardless.
2592
2600
  _mode = _pagewalk.paginate_by()
2593
2601
  pages: list[dict] = []
2602
+ _limited = _warmup_mode and _warmup_up_to_slide is not None and marker_config is not None
2603
+ _kept = len(module_list)
2594
2604
  with hidden.container(), _isolate_widget_keys(), _suppress_cache_build_dom():
2595
2605
  for i, module in enumerate(module_list):
2596
2606
  toc_before = len(toc_entries()) if toc_config else 0
@@ -2657,6 +2667,10 @@ def _build_page_cache(module_list, toc_config, marker_config, separator,
2657
2667
  _mod_name = getattr(module, '__name__', '').rsplit('.', 1)[-1]
2658
2668
  progress_callback(i + 1, len(module_list), _mod_name)
2659
2669
 
2670
+ if _limited and sum(1 for m in marker_entries() if is_stop(m)) >= _warmup_up_to_slide:
2671
+ _kept = i + 1 # the entry holding the slide, whole (#146)
2672
+ break
2673
+
2660
2674
  if separator and i < len(module_list) - 1:
2661
2675
  st_include(separator, *block_args, **block_kwargs)
2662
2676
 
@@ -2691,6 +2705,11 @@ def _build_page_cache(module_list, toc_config, marker_config, separator,
2691
2705
 
2692
2706
  if marker_config:
2693
2707
  annotate_marker_numbers(marker_entries()) # #117
2708
+ if _warmup_mode and _warmup_up_to_slide is not None:
2709
+ global _warmup_limit_result
2710
+ _stops = sum(1 for m in marker_entries() if is_stop(m)) if marker_config else 0
2711
+ _warmup_limit_result = {"up_to_slide": _warmup_up_to_slide, "last_slide": _stops,
2712
+ "entries": _kept, "stops": _stops}
2694
2713
 
2695
2714
  # Store navigation data for CLI export enrichment (sidebar, markers, search)
2696
2715
  if export_config is not None:
@@ -2710,7 +2729,7 @@ def _build_page_cache(module_list, toc_config, marker_config, separator,
2710
2729
  "toc": copy.deepcopy(toc_entries()) if toc_config else [],
2711
2730
  "markers": copy.deepcopy(marker_entries()) if marker_config else [],
2712
2731
  "total": len(pages), # pages (#121)
2713
- "entries": len(module_list),
2732
+ "entries": _kept, # all of them, unless --up-to-slide (#146)
2714
2733
  "paginate_by": _mode,
2715
2734
  "pages": pages,
2716
2735
  "search_index": search_index,
@@ -2753,7 +2772,10 @@ def _warmup_build_cache(module_list, toc_config, marker_config, separator,
2753
2772
  block_args=block_args,
2754
2773
  block_kwargs=block_kwargs)
2755
2774
  cache = st.session_state.get(_STX_CACHE_KEY)
2756
- if cache and cache_path:
2775
+ if _warmup_up_to_slide is not None:
2776
+ # a cut document: never the cache the live book would load (#146)
2777
+ logger.info("Warmup: --up-to-slide, the page cache is not saved.")
2778
+ elif cache and cache_path:
2757
2779
  _save_file_cache(cache_path, cache)
2758
2780
  logger.info("Warmup: saved page cache to %s", cache_path)
2759
2781
  elif not cache_path:
@@ -1,5 +1,6 @@
1
1
  """stx export html — generate static HTML from a StreamTeX project (headless)."""
2
2
 
3
+ import json
3
4
  import os
4
5
  import sys
5
6
  import time
@@ -67,6 +68,9 @@ def _read_streamlit_theme(project_dir: str) -> dict[str, str]:
67
68
  #: single ``STX_LANG=fr`` drives both the content and the ``<html lang>``.
68
69
  LANG_ENV_VAR = "STX_LANG"
69
70
 
71
+ #: Written in the output folder by ``--up-to-slide`` (#146): what was kept.
72
+ LIMIT_FILE = "stx-limit.json"
73
+
70
74
 
71
75
  def resolve_export_lang(lang_option: str | None) -> str:
72
76
  """Resolve the export language: ``--lang`` > ``$STX_LANG`` > ``"en"``."""
@@ -112,8 +116,12 @@ def resolve_export_lang(lang_option: str | None) -> str:
112
116
  @click.option("--page-width", type=float, default=None,
113
117
  help="Width of the page, in percent of the window (e.g. 90), as the "
114
118
  "panel's HTML export does. Default: the library's page width.")
119
+ @click.option("--up-to-slide", type=int, default=None,
120
+ help="Export slides 1 to N only (N on the slide counter): the export stops after "
121
+ "the block that holds slide N, which is kept whole; later blocks never run. "
122
+ "Writes stx-limit.json in the output folder.")
115
123
  def export_html(path, output, asset_mode, title, no_nav, theme_mode, theme_bg, theme_text,
116
- lang, suffix, html_mode, keep_going, zoom, page_width):
124
+ lang, suffix, html_mode, keep_going, zoom, page_width, up_to_slide):
117
125
  """Generate static HTML from a StreamTeX project without a Streamlit server.
118
126
 
119
127
  Exports a fully navigable HTML document with sidebar TOC, floating
@@ -131,6 +139,7 @@ def export_html(path, output, asset_mode, title, no_nav, theme_mode, theme_bg, t
131
139
  stx export html --html-mode both . # continuous + one file per page
132
140
  stx export html --keep-going . # write it even if a block raises
133
141
  stx export html --zoom 80 --lang fr --output ./out/fr . # opens as at 80 %
142
+ stx export html --up-to-slide 12 . # slides 1-12 (their blocks whole)
134
143
  """
135
144
  from ..export import AssetCollector, AssetMode, ExportConfig
136
145
 
@@ -143,6 +152,9 @@ def export_html(path, output, asset_mode, title, no_nav, theme_mode, theme_bg, t
143
152
  if page_width is not None and not 0 < page_width <= 100:
144
153
  console.print(f"[red]Error:[/] --page-width must be a percentage in (0, 100] (got {page_width:g}).")
145
154
  raise SystemExit(1)
155
+ if up_to_slide is not None and up_to_slide < 1:
156
+ console.print(f"[red]Error:[/] --up-to-slide must be a slide number, 1 or more (got {up_to_slide}).")
157
+ raise SystemExit(1)
146
158
  project_dir = os.path.abspath(path)
147
159
  book_py = os.path.join(project_dir, "book.py")
148
160
 
@@ -220,6 +232,8 @@ def export_html(path, output, asset_mode, title, no_nav, theme_mode, theme_bg, t
220
232
  _book_mod._warmup_export_config = export_cfg
221
233
  _book_mod._export_page_sentinels = True # where pages start (#106)
222
234
  _book_mod._html_export_mode = "continuous"
235
+ _book_mod._warmup_up_to_slide = up_to_slide # #146
236
+ _book_mod._warmup_limit_result = None
223
237
 
224
238
  t0 = time.time()
225
239
  try:
@@ -239,6 +253,7 @@ def export_html(path, output, asset_mode, title, no_nav, theme_mode, theme_bg, t
239
253
  _book_mod._warmup_mode = False
240
254
  _book_mod._warmup_export_config = None
241
255
  _book_mod._export_page_sentinels = False
256
+ _book_mod._warmup_up_to_slide = None
242
257
  os.chdir(original_cwd)
243
258
 
244
259
  # Retrieve the captured HTML and nav data while session_state is the mock dict
@@ -273,6 +288,18 @@ def export_html(path, output, asset_mode, title, no_nav, theme_mode, theme_bg, t
273
288
  )
274
289
  raise SystemExit(1)
275
290
 
291
+ limit = None
292
+ if up_to_slide is not None:
293
+ limit = _book_mod._warmup_limit_result
294
+ if not limit or not limit["stops"]:
295
+ console.print("[red]Error:[/] --up-to-slide: the document has no slide stops "
296
+ "(markers) to count; nothing is written.")
297
+ raise SystemExit(1)
298
+ short = "" if limit["last_slide"] >= up_to_slide else \
299
+ f" — the document has {limit['last_slide']} slide(s) only"
300
+ console.print(f"[green]\u2713 Limit:[/] slides 1 to {limit['last_slide']}, "
301
+ f"block(s) 1 to {limit['entries']}{short}")
302
+
276
303
  from ..export import strip_page_sentinels
277
304
  from ..export_paginate import build_entry_html, build_page_documents, to_subfolder
278
305
 
@@ -345,6 +372,10 @@ def export_html(path, output, asset_mode, title, no_nav, theme_mode, theme_bg, t
345
372
  collector = AssetCollector() if use_external else None
346
373
  folder = Path(output_dir) / base_name if use_external else Path(output_dir)
347
374
  continuous_name = f"{base_name}.html"
375
+ if limit is not None:
376
+ # what was kept, for `stx release limit` (#146)
377
+ Path(output_dir).mkdir(parents=True, exist_ok=True)
378
+ (Path(output_dir) / LIMIT_FILE).write_text(json.dumps(limit) + "\n", encoding="utf-8")
348
379
 
349
380
  # Page files first: they register their assets in the shared collector
350
381
  if paged is not None:
@@ -35,26 +35,18 @@ def release():
35
35
  """Publish the sites of a multi-document project: two long-lived applications, snapshots, rollback."""
36
36
 
37
37
 
38
- @release.command("publish")
39
- @click.argument("sites", nargs=-1)
40
- @click.option("--group", "groups", multiple=True, help="Publish every site of this group (repeatable).")
41
- @_target
42
- @click.option("--allow-skew", is_flag=True,
43
- help="Publish although the exporting streamtex is not the live image's (marked in status).")
44
- @click.option("--html-env", "html_env", multiple=True, metavar="KEY=VALUE",
45
- help="An environment variable for the HTML export only (e.g. a partial deck).")
46
- def publish_cmd(sites, groups, target, allow_skew, html_env):
47
- """Publish SITES (default: every site not marked explicit): both faces together, all or nothing."""
48
- cfg, state, t = _ctx(target)
49
- chosen = cfg.select(sites, groups)
38
+ def _html_env(items) -> dict[str, str]:
50
39
  env = {}
51
- for item in html_env:
40
+ for item in items:
52
41
  if "=" not in item:
53
42
  raise ReleaseError(f"--html-env {item!r}: expected KEY=VALUE")
54
43
  k, v = item.split("=", 1)
55
44
  env[k] = v
56
- release_name = build.require_committed(cfg.root)
57
- build.require_lock(cfg)
45
+ return env
46
+
47
+
48
+ def _skew(cfg, t, allow_skew: bool) -> str:
49
+ """Why the exporting streamtex is not the live image's, refused unless --allow-skew (rel version=a)."""
58
50
  skew = build.library_skew(cfg)
59
51
  running = ops.image_version(t)
60
52
  wanted = (cfg.lock_dir / "stx-version").read_text(encoding="utf-8").strip()
@@ -67,6 +59,25 @@ def publish_cmd(sites, groups, target, allow_skew, html_env):
67
59
  raise ReleaseError(f"{skew} — publish with the image's streamtex, or pass --allow-skew for a trial")
68
60
  if skew:
69
61
  click.echo(f" ⚠ {skew} (--allow-skew: the sites are marked in status)")
62
+ return skew
63
+
64
+
65
+ @release.command("publish")
66
+ @click.argument("sites", nargs=-1)
67
+ @click.option("--group", "groups", multiple=True, help="Publish every site of this group (repeatable).")
68
+ @_target
69
+ @click.option("--allow-skew", is_flag=True,
70
+ help="Publish although the exporting streamtex is not the live image's (marked in status).")
71
+ @click.option("--html-env", "html_env", multiple=True, metavar="KEY=VALUE",
72
+ help="An environment variable for the HTML export only (e.g. a partial deck).")
73
+ def publish_cmd(sites, groups, target, allow_skew, html_env):
74
+ """Publish SITES (default: every site not marked explicit): both faces together, all or nothing."""
75
+ cfg, state, t = _ctx(target)
76
+ chosen = cfg.select(sites, groups)
77
+ env = _html_env(html_env)
78
+ release_name = build.require_committed(cfg.root)
79
+ build.require_lock(cfg)
80
+ skew = _skew(cfg, t, allow_skew)
70
81
  run_checks(cfg, chosen)
71
82
  data = _passwords(cfg)
72
83
  faces = {s.site: pw.for_site(data, s) for s in chosen} # every password checked before any copy
@@ -91,18 +102,55 @@ def status_cmd(target):
91
102
  click.echo(f"target {t.name} · HEAD {head} · live image streamtex {running} (stx-version {wanted}){gap}\n")
92
103
  rows = ops.status_rows(t, cfg, state, data)
93
104
  w = max([28] + [len(r[0]) + 2 for r in rows])
94
- click.echo(f"{'site':<{w}}{'published':<14}{'served (html)':<17}{'live':<8}{'html':<11}date")
105
+ click.echo(f"{'site':<{w}}{'published':<14}{'served (html)':<19}{'live':<8}{'html':<11}date")
95
106
  for name, rel, html, live, access, date, flag in rows:
96
- click.echo(f"{name:<{w}}{rel:<14}{html:<17}{live:<8}{access:<11}{date}{flag}")
107
+ click.echo(f"{name:<{w}}{rel:<14}{html:<19}{live:<8}{access:<11}{date}{flag}")
108
+
109
+
110
+ @release.command("limit")
111
+ @click.argument("site")
112
+ @click.argument("slide")
113
+ @_target
114
+ @click.option("--allow-skew", is_flag=True,
115
+ help="Export although the exporting streamtex is not the live image's.")
116
+ @click.option("--html-env", "html_env", multiple=True, metavar="KEY=VALUE",
117
+ help="An environment variable for the HTML export.")
118
+ def limit_cmd(site, slide, target, allow_skew, html_env):
119
+ """What participants see on SITE's HTML face: slides 1 to SLIDE, or `all`.
120
+
121
+ \b
122
+ The number is the slide counter's (n / N), as projected; the block that holds
123
+ that slide is kept whole, and later blocks are not exported at all. Only the
124
+ HTML face is exported again, from the release already published, and switched:
125
+ no password is rewritten and the live face does not restart, so participants
126
+ stay logged in. The limit is kept: every later `publish SITE` applies it, and
127
+ `rollback SITE` undoes it alone.
128
+
129
+ \b
130
+ Examples:
131
+ stx release limit gai4as-slides 120
132
+ stx release limit gai4as-slides all
133
+ """
134
+ if slide == "all":
135
+ up_to = None
136
+ elif slide.isdigit() and int(slide) >= 1:
137
+ up_to = int(slide)
138
+ else:
139
+ raise ReleaseError(f"{slide!r}: a slide number (1 or more) or `all`")
140
+ cfg, state, t = _ctx(target)
141
+ s = cfg.site(site)
142
+ _skew(cfg, t, allow_skew)
143
+ html_pw = "" if "html" not in s.faces else pw.first_password(pw.for_site(_passwords(cfg), s)["html"])
144
+ ops.limit_site(t, cfg, state, s, up_to, html_pw, click.echo, _html_env(html_env))
97
145
 
98
146
 
99
147
  @release.command("rollback")
100
148
  @click.argument("site")
101
149
  @_target
102
150
  def rollback_cmd(site, target):
103
- """Put both faces of SITE back on its previous release."""
151
+ """Undo SITE's last change: a limit (the HTML face alone), else a publication (both faces)."""
104
152
  cfg, state, t = _ctx(target)
105
- click.echo(f"{site}: both faces are back on {ops.rollback(t, cfg, state, cfg.site(site))}")
153
+ click.echo(f"{site}: {ops.rollback(t, cfg, state, cfg.site(site))}")
106
154
 
107
155
 
108
156
  @release.command("passwd")
@@ -80,7 +80,7 @@ from pathlib import Path
80
80
  from urllib.parse import parse_qs, urlsplit
81
81
 
82
82
  #: The library release this file ships with, and its interface number (#135).
83
- STX_VERSION = "0.7.63"
83
+ STX_VERSION = "0.7.65"
84
84
  AUTH_INTERFACE = 1
85
85
 
86
86
  DEFAULT_ROOT = "/var/lib/stx-auth"
@@ -11,12 +11,14 @@ No ``st.html()`` calls here — satisfies ``test_export_guard.py``.
11
11
  from __future__ import annotations
12
12
 
13
13
  import base64
14
+ import functools
14
15
  import io
15
16
  import json
16
17
  import os
17
18
  import re
19
+ import struct
18
20
  from typing import TYPE_CHECKING
19
- from urllib.parse import urlsplit
21
+ from urllib.parse import quote, urlsplit
20
22
 
21
23
  if TYPE_CHECKING:
22
24
  import pandas as pd
@@ -218,13 +220,73 @@ _VIDEO_MIME = {
218
220
  }
219
221
 
220
222
 
223
+ # Streamlit's own limit for a file of the app's ``static`` folder.
224
+ _SERVED_MAX_BYTES = 200 * 1024 * 1024
225
+
226
+
227
+ def _static_rel(data) -> str | None:
228
+ """The path of a local *data* file inside the app's ``static`` folder, or None (#140).
229
+
230
+ Streamlit serves that folder at ``/app/static/``. A video or a sound
231
+ found there is played from that URL, instead of being read whole into
232
+ memory at every run, and the HTML export takes it as a served file. Not
233
+ for a file reached through a link that leaves the folder, nor one over
234
+ 200 MB: Streamlit refuses to serve both.
235
+ """
236
+ if isinstance(data, os.PathLike):
237
+ data = os.fspath(data)
238
+ if (not isinstance(data, str) or data.startswith(("http://", "https://", "www.", "data:"))
239
+ or not os.path.isfile(data)):
240
+ return None
241
+ from .image_crop import _app_static_dir
242
+ root = _app_static_dir()
243
+ root_real = os.path.realpath(root)
244
+ for path, base in ((os.path.abspath(data), os.path.abspath(root)),
245
+ (os.path.realpath(data), root_real)):
246
+ try:
247
+ rel = os.path.relpath(path, base)
248
+ except ValueError: # another drive
249
+ continue
250
+ if rel != os.pardir and not rel.startswith(os.pardir + os.sep):
251
+ break
252
+ else:
253
+ return None
254
+ if not os.path.realpath(os.path.join(root_real, rel)).startswith(root_real + os.sep):
255
+ return None
256
+ if os.path.getsize(data) > _SERVED_MAX_BYTES:
257
+ return None
258
+ return rel.replace(os.sep, "/")
259
+
260
+
261
+ def _live_source(data):
262
+ """What ``st.video`` / ``st.audio`` receives: a served URL for a file of ``static`` (#140).
263
+
264
+ Streamlit plays a ``/app/static/`` URL as it is, without its media file
265
+ manager. Without static serving (``server.enableStaticServing``), or for
266
+ any other source, *data* is passed on unchanged.
267
+ """
268
+ rel = _static_rel(data)
269
+ if rel is None:
270
+ return data
271
+ try:
272
+ serving = st.get_option("server.enableStaticServing")
273
+ except Exception: # pragma: no cover — Streamlit version drift
274
+ serving = False
275
+ return "/app/static/" + quote(rel) if serving else data
276
+
277
+
221
278
  def _media_src(data, mime_map: dict, format_hint: str | None) -> tuple[str, str]:
222
279
  """Return ``(src_attr, mime)`` for an ``<audio>`` or ``<video>`` tag.
223
280
 
224
281
  *data* can be a file path (str), a URL (str), or raw bytes. For a URL,
225
282
  the type comes from the extension of its path; an unknown one gives
226
283
  ``""``, and the ``<source>`` is then written without ``type`` (#114).
284
+ A file of the app's ``static`` folder becomes ``app/static/…``, which
285
+ the export copies into its ``data/`` folder (#140); another local file
286
+ is inlined.
227
287
  """
288
+ if isinstance(data, os.PathLike):
289
+ data = os.fspath(data)
228
290
  if isinstance(data, (bytes, bytearray)):
229
291
  mime = format_hint or "application/octet-stream"
230
292
  b64 = base64.b64encode(data).decode()
@@ -237,6 +299,9 @@ def _media_src(data, mime_map: dict, format_hint: str | None) -> tuple[str, str]
237
299
  # Local file path
238
300
  ext = os.path.splitext(data)[1].lower()
239
301
  mime = format_hint or mime_map.get(ext, "application/octet-stream")
302
+ rel = _static_rel(data)
303
+ if rel is not None:
304
+ return f"app/static/{rel}", mime
240
305
  try:
241
306
  with open(data, "rb") as f:
242
307
  b64 = base64.b64encode(f.read()).decode()
@@ -270,31 +335,141 @@ _CSS_LENGTH_RE = re.compile(r"^\d+(\.\d+)?(px|%|vw|vh|em|rem)$")
270
335
  _warned_autoplay = False
271
336
 
272
337
 
273
- def _media_box(width, align: str):
338
+ def _media_box(width, align: str, max_vw=None, max_vh=None, ratio: float | None = None):
274
339
  """The st_block that sizes and places a media player (#126), or None.
275
340
 
276
341
  *width* is None (the full width, no box), pixels (``int``) or a CSS length
277
342
  (``"50%"``, ``"60vw"``, ``"800px"``); *align* places the narrower box. The
278
343
  player stretches inside it, live and in the export (the block's wrapper).
344
+ *max_vw* / *max_vh* bound the box (#141): its width becomes
345
+ ``min(width, max_vw vw, max_vh vh × ratio)``; without a *ratio* the
346
+ height bound cannot be turned into a width and is left out.
279
347
  """
280
348
  if align not in _ALIGN_MARGINS:
281
349
  raise ValueError(f"align must be 'center', 'left' or 'right', not {align!r}")
282
- if width is None:
350
+ if width is None and max_vw is None and max_vh is None:
283
351
  return None
284
- if isinstance(width, bool) or not isinstance(width, (int, str)):
285
- raise ValueError(f"width must be pixels (int) or a CSS length such as '50%', not {width!r}")
286
- length = f"{width}px" if isinstance(width, int) else width.strip()
287
- if not _CSS_LENGTH_RE.match(length):
288
- raise ValueError(f"width must be pixels (int) or a CSS length such as '50%', '60vw', '800px', not {width!r}")
352
+ if width is None:
353
+ length = "100%"
354
+ else:
355
+ if isinstance(width, bool) or not isinstance(width, (int, str)):
356
+ raise ValueError(f"width must be pixels (int) or a CSS length such as '50%', not {width!r}")
357
+ length = f"{width}px" if isinstance(width, int) else width.strip()
358
+ if not _CSS_LENGTH_RE.match(length):
359
+ raise ValueError(
360
+ f"width must be pixels (int) or a CSS length such as '50%', '60vw', '800px', not {width!r}")
361
+ parts = [length]
362
+ if max_vw is not None:
363
+ parts.append(f"{_num(max_vw)}vw")
364
+ if max_vh is not None and ratio is not None:
365
+ parts.append(f"calc({_num(max_vh)}vh * {ratio:.6f})")
366
+ if len(parts) > 1:
367
+ length = f"min({', '.join(parts)})"
289
368
  from .container import st_block
290
369
  from .styles import Style
291
370
  return st_block(Style(f"width:{length};max-width:100%;{_ALIGN_MARGINS[align]}", "stx_media_box"))
292
371
 
293
372
 
373
+ def _num(value: float) -> str:
374
+ return f"{value:.4f}".rstrip("0").rstrip(".")
375
+
376
+
377
+ # -- the picture size of a video (#141) --------------------------------------
378
+
379
+ _MP4_HEAD = 1 << 20 # the header of a "faststart" MP4 lies in its first MiB
380
+ _warned_ratio: set = set()
381
+
382
+
383
+ def _mp4_boxes(buf: bytes, start: int, end: int):
384
+ """``(type, payload start, payload end, complete)`` of the boxes in ``buf[start:end]``."""
385
+ i = start
386
+ while i + 8 <= end:
387
+ size, kind = struct.unpack(">I4s", buf[i:i + 8])
388
+ head = 8
389
+ if size == 1:
390
+ if i + 16 > end:
391
+ return
392
+ size, head = struct.unpack(">Q", buf[i + 8:i + 16])[0], 16
393
+ elif size == 0:
394
+ size = end - i
395
+ if size < head:
396
+ return
397
+ yield kind, i + head, min(i + size, end), i + size <= end
398
+ i += size
399
+
400
+
401
+ def _tkhd_size(buf: bytes, start: int, end: int) -> tuple[float, float] | None:
402
+ """The displayed size in the first ``tkhd`` with a picture (audio tracks have 0 × 0)."""
403
+ for kind, a, b, complete in _mp4_boxes(buf, start, end):
404
+ if kind in (b"moov", b"trak"):
405
+ size = _tkhd_size(buf, a, b)
406
+ if size:
407
+ return size
408
+ elif kind == b"tkhd" and complete and b - a >= 84:
409
+ matrix = struct.unpack(">9i", buf[b - 44:b - 8])
410
+ w, h = (v / 65536 for v in struct.unpack(">II", buf[b - 8:b]))
411
+ if w > 0 and h > 0:
412
+ # a quarter turn (a phone held upright) swaps the sides on screen
413
+ return (h, w) if matrix[0] == 0 and matrix[4] == 0 else (w, h)
414
+ return None
415
+
416
+
417
+ @functools.lru_cache(maxsize=256)
418
+ def _mp4_size(path: str, mtime: float) -> tuple[float, float] | None:
419
+ """Width and height of an MP4 / MOV picture, read in its first MiB, or None."""
420
+ try:
421
+ with open(path, "rb") as f:
422
+ head = f.read(_MP4_HEAD)
423
+ except OSError:
424
+ return None
425
+ return _tkhd_size(head, 0, len(head))
426
+
427
+
428
+ def _video_ratio(data, natural_size) -> float | None:
429
+ """Width / height of the picture: *natural_size*, else read from a local MP4.
430
+
431
+ Warns once per source when it cannot be read: the height bound is then
432
+ left out.
433
+ """
434
+ if natural_size is not None:
435
+ return natural_size[0] / natural_size[1]
436
+ if isinstance(data, os.PathLike):
437
+ data = os.fspath(data)
438
+ size = None
439
+ if isinstance(data, str) and os.path.isfile(data):
440
+ size = _mp4_size(os.path.abspath(data), os.path.getmtime(data))
441
+ if size:
442
+ return size[0] / size[1]
443
+ key = data if isinstance(data, str) else type(data).__name__
444
+ if key not in _warned_ratio:
445
+ _warned_ratio.add(key)
446
+ import logging
447
+ logging.getLogger(__name__).warning(
448
+ "st_video(max_vh=): the picture size of %s cannot be read, so the height bound is "
449
+ "left out. An MP4 needs its header first (ffmpeg -movflags +faststart); otherwise "
450
+ "give natural_size=(width, height).", key)
451
+ return None
452
+
453
+
454
+ def _check_bounds(max_vw, max_vh, natural_size) -> None:
455
+ for name, bound in (("max_vw", max_vw), ("max_vh", max_vh)):
456
+ if bound is not None and (isinstance(bound, bool) or not isinstance(bound, (int, float))
457
+ or bound <= 0):
458
+ raise ValueError(f"{name} must be a positive number of {name[-2:]} units, not {bound!r}")
459
+ if natural_size is not None:
460
+ if max_vw is None and max_vh is None:
461
+ raise ValueError("natural_size= goes with max_vw= / max_vh=")
462
+ if (not isinstance(natural_size, (tuple, list)) or len(natural_size) != 2
463
+ or any(isinstance(v, bool) or not isinstance(v, (int, float)) or v <= 0
464
+ for v in natural_size)):
465
+ raise ValueError(f"natural_size must be (width, height), two positive numbers, not {natural_size!r}")
466
+
467
+
294
468
  def st_audio(data, *, width: int | str | None = None, align: str = "center", **kw) -> None:
295
469
  """Display audio with ``st.audio()`` and export an ``<audio>`` tag.
296
470
 
297
- *width* / *align*: as for :func:`st_video` (#126).
471
+ *width* / *align*, and a file under ``static/``: as for :func:`st_video`
472
+ (#126, #140).
298
473
  """
299
474
  box = _media_box(width, align)
300
475
  if box is None:
@@ -305,7 +480,7 @@ def st_audio(data, *, width: int | str | None = None, align: str = "center", **k
305
480
 
306
481
 
307
482
  def _audio(data, _boxed: bool = False, **kw):
308
- st.audio(data, **kw)
483
+ st.audio(_live_source(data), **kw)
309
484
  if is_export_active():
310
485
  fmt = kw.get("format")
311
486
  src, mime = _media_src(data, _AUDIO_MIME, fmt)
@@ -318,6 +493,8 @@ def _audio(data, _boxed: bool = False, **kw):
318
493
 
319
494
 
320
495
  def st_video(data, *, width: int | str | None = None, align: str = "center",
496
+ max_vw: float | None = None, max_vh: float | None = None,
497
+ natural_size: tuple[float, float] | None = None,
321
498
  theater: bool | str = False, fit: str = "contain", fullscreen: bool = False,
322
499
  **kw) -> None:
323
500
  """Display video with ``st.video()`` and export a ``<video>`` or YouTube embed.
@@ -337,6 +514,24 @@ def st_video(data, *, width: int | str | None = None, align: str = "center",
337
514
  explicit ``muted=False`` is kept: a browser that allows sound on its own
338
515
  (a projection profile) plays it with sound, others wait for a click.
339
516
 
517
+ *max_vw* / *max_vh* (#141), as in :func:`st_image`: the largest
518
+ width in % of the window width, and the largest height in % of the
519
+ window height. The player takes the largest size within *width* (the
520
+ container by default) and both bounds, without distortion:
521
+ ``st_video(clip, max_vw=100, max_vh=50)`` gives a 960 × 540 player for
522
+ a 16:9 clip in a 1920 × 1080 window, and fills a narrow window's
523
+ width. The picture's shape is read from a local MP4 (its header must
524
+ come first: ``ffmpeg -movflags +faststart``); for a URL or another
525
+ file, give *natural_size* ``(width, height)``. When it cannot be read,
526
+ one warning is logged and only *max_vw* applies. Inside ``st_zoom``,
527
+ the bounds are multiplied by the zoom like any length. Not with
528
+ *theater*.
529
+
530
+ A local file under the app's ``static/`` folder (static serving on) is
531
+ played from its ``/app/static/…`` URL, not read into memory at every
532
+ run, and the HTML export copies it into ``data/`` (#140). Put large
533
+ videos there.
534
+
340
535
  A video that dominates the screen (#56), live and in the HTML export:
341
536
 
342
537
  - *theater*: ``"slide"`` (or ``True``) fills the screen height in the
@@ -367,10 +562,22 @@ def st_video(data, *, width: int | str | None = None, align: str = "center",
367
562
  raise ValueError(f"fit must be 'contain' or 'cover', not {fit!r}")
368
563
  if not isinstance(fullscreen, bool):
369
564
  raise ValueError(f"fullscreen must be True or False, not {fullscreen!r}")
370
- if mode or fullscreen:
565
+ bounded = max_vw is not None or max_vh is not None
566
+ _check_bounds(max_vw, max_vh, natural_size)
567
+ if mode and bounded:
568
+ raise ValueError("max_vw / max_vh do not apply with theater=: the theater sizes the video")
569
+ if mode:
371
570
  _staged_video(data, mode, fit, fullscreen, kw)
372
571
  return
373
- box = _media_box(width, align)
572
+ ratio = _video_ratio(data, natural_size) if max_vh is not None else None
573
+ box = _media_box(width, align, max_vw, max_vh, ratio)
574
+ if fullscreen:
575
+ if box is None:
576
+ _staged_video(data, mode, fit, fullscreen, kw)
577
+ return
578
+ with box:
579
+ _staged_video(data, mode, fit, fullscreen, kw)
580
+ return
374
581
  if box is None:
375
582
  _video(data, **kw)
376
583
  return
@@ -405,7 +612,7 @@ def _staged_video(data, mode: str, fit: str, fullscreen: bool, kw: dict) -> None
405
612
  '&times;</button>' if mode == "window" else "")
406
613
  with st.container():
407
614
  st.markdown(marker + close, unsafe_allow_html=True)
408
- st.video(data, **kw)
615
+ st.video(_live_source(data), **kw)
409
616
  if is_export_active():
410
617
  classes = "stx-vbox" + (f" stx-theater-{mode}" if mode else "") + f" stx-fit-{fit}"
411
618
  export_append(f'<div class="stx-vbox-slot"><div class="{classes}">{marker}{close}'
@@ -413,7 +620,7 @@ def _staged_video(data, mode: str, fit: str, fullscreen: bool, kw: dict) -> None
413
620
 
414
621
 
415
622
  def _video(data, _boxed: bool = False, **kw):
416
- st.video(data, **kw)
623
+ st.video(_live_source(data), **kw)
417
624
  if is_export_active():
418
625
  export_append(_video_export_html(data, _boxed, kw))
419
626
 
@@ -106,7 +106,9 @@ def st_image(
106
106
  ``"auto"``. When the natural size cannot be read (remote URI
107
107
  without `natural_size`), the bounds become ``max-width`` /
108
108
  ``max-height`` (the image is then never enlarged). Both `None`
109
- (default) keeps the emitted HTML strictly identical.
109
+ (default) keeps the emitted HTML strictly identical. Inside
110
+ ``st_zoom``, the bounds are multiplied by the zoom like any
111
+ length: ``max_vh=50`` in ``st_zoom(130)`` is 65 vh on screen.
110
112
 
111
113
  :param align: Optional ``"left"`` / ``"center"`` / ``"right"``: place
112
114
  this image, contradicting its container locally. By default the
@@ -6,7 +6,8 @@ a live one (one Streamlit process per site under supervisord, an nginx router ho
6
6
  *site* is one document with up to two *faces* (``live``, ``html``), published together, all or nothing:
7
7
  code snapshot → HTML export on this machine, checked → copy of the delta over SSH (``rsync
8
8
  --link-dest``) → passwords → both faces switch together → restart of that site's process only → check
9
- of what is actually served, and back to the previous snapshot when a check fails.
9
+ of what is actually served, and back to the previous snapshot when a check fails. A slide limit per
10
+ site (``limit``, #146) changes the HTML face alone, from the published snapshot.
10
11
 
11
12
  Modules: ``config`` (``[release]`` of stx.toml, the site list), ``state`` (``.stx-release.json``,
12
13
  versioned, no secret), ``target`` (where to publish: ``local`` Docker or ``ssh``), ``passwords``