w3c / publishingcg

Repository of the Publishing Community Group
https://www.w3.org/community/publishingcg/
Other
19 stars 6 forks source link

EPUB Renditions and Indicating JavaScript Feature Requirements #31

Open AdamSobieski opened 2 years ago

AdamSobieski commented 2 years ago

Hello. I would like to propose a new attribute for the EPUB Multiple Renditions specification and model.

"The need to include more than one Rendition of an EPUB Publication has grown as Reading Systems have evolved and become more sophisticated. While some measure of content adaptation has always been possible at the style sheet level, it is both limited in what it can accomplish and limited to content rendering. Existing fallback mechanisms within the Package Document similarly only ensure that resources can be rendered."

Presently, the EPUB Multiple Renditions model provides a means of differentiating between Renditions via a number of markup attributes: rendition:media, rendition:layout, rendition:language, rendition:accessMode, and rendition:label.

The rendition:media attribute identifies the media features of a Reading System the given Rendition is best suitable for rendering on.

<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container"
           xmlns:rendition="http://www.idpf.org/2013/rendition"
           version="1.0">
   <rootfiles>
       <rootfile full-path="Sandman.opf"
           media-type="application/oebps-package+xml"/>
       <rootfile full-path="Sandman-large.opf"
           media-type="application/oebps-package+xml"
           rendition:media="(min-width: 1920px)"/>
   </rootfiles>
</container>

The rendition:layout attribute indicates whether the given Rendition is reflowable or pre-paginated.

<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container"
           xmlns:rendition="http://www.idpf.org/2013/rendition"
           version="1.0">
   <rootfiles>
       <rootfile full-path="EPUB/reflow/magazine.opf"
           media-type="application/oebps-package+xml"/>
       <rootfile full-path="EPUB/fxl/magazine.opf"
           media-type="application/oebps-package+xml"
           rendition:layout="pre-paginated"/>
    </rootfiles>
</container>

The rendition:language attribute indicates that the given Rendition is optimized for the specified language.

<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container"
           xmlns:rendition="http://www.idpf.org/2013/rendition"
           version="1.0">
   <rootfiles>
       <rootfile full-path="EPUB/en/package.opf"
           media-type="application/oebps-package+xml"
           rendition:language="en"/>
       <rootfile full-path="EPUB/fr/package.opf"
           media-type="application/oebps-package+xml"
           rendition:language="fr"/>
       <rootfile full-path="EPUB/es/package.opf"
           media-type="application/oebps-package+xml"
           rendition:language="es"/>
   </rootfiles>
</container>

The rendition:accessMode attribute identifies the way in which intellectual content is communicated in a Rendition, and is based on the [ISO24751-3] "Access Mode" property (e.g., auditory, tactile, textual, or visual).

<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container"
           xmlns:rendition="http://www.idpf.org/2013/rendition"
           version="1.0">
   <rootfiles>
       <rootfile full-path="EPUB/comic/package.opf"
           media-type="application/oebps-package+xml"
           rendition:accessMode="visual"/>
       <rootfile full-path="EPUB/novel/package.opf"
           media-type="application/oebps-package+xml"
           rendition:accessMode="textual"/>
   </rootfiles>
</container>

The rendition:label attribute allows each rootfile element to be annotated with a human-readable name.

<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container"
           xmlns:rendition="http://www.idpf.org/2013/rendition"
           version="1.0"
           xml:lang="en">
   <rootfiles>
        …
       <rootfile full-path="EPUB/package.opf"
           media-type="application/oebps-package+xml"
           rendition:media="color, min-width: 1024"
           rendition:layout="pre-paginated"
           rendition:label="Color-optimized print replica"/>
   </rootfiles>
</container>

Proposed, here, is a new attribute for the rendition XMLNS, rendition:requires. This new attribute would be useful for indicating that a Rendition requires JavaScript or, more granularly, that it requires specific JavaScript features.

The following example shows how one could express that a Rendition requires JavaScript:

<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container"
           xmlns:rendition="http://www.idpf.org/2013/rendition"
           version="1.0"
           xml:lang="en">
   <rootfiles>
        …
       <rootfile full-path="EPUB/package.opf"
           media-type="application/oebps-package+xml"
           rendition:media="color, min-width: 1024"
           rendition:layout="pre-paginated"
           rendition:label="Color-optimized print replica"
           rendition:requires="javascript"/>
   </rootfiles>
</container>

The following example shows how one could express that a Rendition requires more granular JavaScript features:

<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container"
           xmlns:rendition="http://www.idpf.org/2013/rendition"
           version="1.0"
           xml:lang="en">
   <rootfiles>
        …
       <rootfile full-path="EPUB/package.opf"
           media-type="application/oebps-package+xml"
           rendition:media="color, min-width: 1024"
           rendition:layout="pre-paginated"
           rendition:label="Color-optimized print replica"
           rendition:requires="js-feature1 js-feature2 js-feature3"/>
   </rootfiles>
</container>
iherman commented 2 years ago

@AdamSobieski how would you define javascript features? Is there an existing specification that we could rely on?

AdamSobieski commented 2 years ago

@iherman, the closest specifications that I can find on these topics are:

  1. https://w3c.github.io/permissions/
  2. https://w3c.github.io/permissions-registry/
  3. https://w3c.github.io/webappsec-permissions-policy/
  4. https://github.com/w3c/webappsec-permissions-policy/blob/main/permissions-policy-explainer.md

In (4), a list of examples is provided: battery status, client hints, encrypted media decoding, fullscreen, geolocation, picture-in-picture, sensors (accelerometer, ambient light sensor, gyroscope, magnetometer), user media (camera, microphone), video autoplay, web payment request, WebMIDI, WebUSB, and WebXR.