juno.sharing

Present the iOS share sheet (UIActivityViewController).

A single share() call shows the system share sheet with whichever of text / url / file you pass; the user picks a share target (Mail, Messages, AirDrop, Copy, …) and the function returns when they either complete an activity or dismiss the sheet.

Typical usage:

from juno import sharing

# Plain text — easy to copy / message
sharing.share(text="Found this on Juno: https://example.test")

# Share an open URL (the browser, target apps treat it as a link)
sharing.share(url="https://docs.python.org")

# Share a file by path
sharing.share(file="/path/to/report.pdf")

# Share generated bytes — the wrapper writes to a tempfile,
# passes its path to the share sheet, and cleans up afterwards.
pdf_bytes = render_report()
sharing.share(file=pdf_bytes)

# Combinable — many share targets can take multiple items
sharing.share(
    text="Latest run output",
    file="/path/to/report.pdf",
)

Notes:

  • url is shared as a URL object; the system recognises it and many targets render it as a tappable link rather than plain text.

  • file accepts either a filesystem path string OR a bytes-like object. The bytes case writes to a tempfile under the app’s caches directory; the file is removed after the share sheet dismisses (synchronous read is the iOS norm — share targets buffer file content during the sheet’s lifetime).

  • Stop is responsive while the share sheet is on screen — the wait is interruptible via KeyboardInterrupt.

juno.sharing.share(*, text=None, url=None, file=None)

Present the iOS share sheet.

At least one of text / url / file must be provided; multiple may be combined and the user’s chosen target decides how to render them.

Parameters:
  • text (str | None) – Plain text to share. None to omit.

  • url (str | None) – A URL string ("https://...", "file://...", …). None to omit. Empty strings are rejected.

  • file (str | bytes | bytearray | memoryview | None) – A filesystem path (str) OR a bytes-like object. If bytes, the wrapper writes to a tempfile, shares the path, and removes the tempfile after the share sheet dismisses. None to omit. Empty strings / empty bytes are rejected.

Returns:

True if the user completed an activity (the system marked the action as performed). False if they dismissed the sheet without picking a target, or if the wait was interrupted.

Raises:
  • TypeError – If any argument has the wrong type.

  • ValueError – If no item was provided, or any provided item is empty.

  • RuntimeError – If a tempfile for bytes input could not be created.

Return type:

bool