From f46cbfdfefb22a4e81576120016328e882f11570 Mon Sep 17 00:00:00 2001 From: eyelidlessness Date: Thu, 17 Apr 2025 07:38:58 -0700 Subject: [PATCH] Substantially narrower design for adding media to label interfaces --- .../xforms-engine/src/client/TextRange.ts | 40 +++++++++++++++++++ .../src/client/media/AudioMediaResource.ts | 6 +++ .../src/client/media/BaseMediaResource.ts | 21 ++++++++++ .../media/BaseStreamableMediaResource.ts | 18 +++++++++ .../src/client/media/ImageMediaResource.ts | 16 ++++++++ .../src/client/media/MediaResource.ts | 15 +++++++ .../src/client/media/MediaResourceURL.ts | 5 +++ .../src/client/media/VideoMediaResource.ts | 6 +++ 8 files changed, 127 insertions(+) create mode 100644 packages/xforms-engine/src/client/media/AudioMediaResource.ts create mode 100644 packages/xforms-engine/src/client/media/BaseMediaResource.ts create mode 100644 packages/xforms-engine/src/client/media/BaseStreamableMediaResource.ts create mode 100644 packages/xforms-engine/src/client/media/ImageMediaResource.ts create mode 100644 packages/xforms-engine/src/client/media/MediaResource.ts create mode 100644 packages/xforms-engine/src/client/media/MediaResourceURL.ts create mode 100644 packages/xforms-engine/src/client/media/VideoMediaResource.ts diff --git a/packages/xforms-engine/src/client/TextRange.ts b/packages/xforms-engine/src/client/TextRange.ts index b490c2e7e..44b541056 100644 --- a/packages/xforms-engine/src/client/TextRange.ts +++ b/packages/xforms-engine/src/client/TextRange.ts @@ -1,4 +1,7 @@ import type { ActiveLanguage } from './FormLanguage.ts'; +import type { AudioMediaResource } from './media/AudioMediaResource.ts'; +import type { ImageMediaResource } from './media/ImageMediaResource.ts'; +import type { VideoMediaResource } from './media/VideoMediaResource.ts'; import type { RootNodeState } from './RootNode.ts'; /** @@ -57,6 +60,19 @@ import type { RootNodeState } from './RootNode.ts'; * opaque (as in, the `jr:itext` implementation is encapsulated in the `xpath` * package, and the engine doesn't really deal with itext translations at the * node level at all). + * + * @todo Once media is parsed ({@link TextRange.audio}, {@link TextRange.image}, + * {@link TextRange.video}), the 'translation' case will be parsed as a node + * rather than as a string. That will unblock output-in-itext. If a minimal + * first pass is to retain the current 'translation' interface, it will need to + * reproduce the bug preventing output-in-itext functionality by identifying the + * (potentially media-adjacent) `` node and casting it back to a string. + * Future iterations could then remove this reproduction-of-bug, allowing + * output-in-itext to work as expected... at which point the design for the + * 'translation' will have increased depth (i.e. establishing {@link TextRange} + * as a tree rather than a list). Alternatively, the 'translation' case could be + * hoisted up to {@link TextRange} to preserve the current depth (until support + * for Markdown would, potentially, establish a tree). */ // prettier-ignore export type TextChunkSource = @@ -147,6 +163,26 @@ export type TextOrigin = * reasoned about differently by clients depending on their role (for instance, * a text range's role may correspond to the "short" or "guidance" `form` of a * {@link https://getodk.github.io/xforms-spec/#languages | translation}). + * + * @todo In following revisions, this could: + * + * - be renamed `RichText` to better represent its semantics + * - support cases with multiple text variants (`