@pie-qti/qti-common 1.0.0-beta.0 → 1.0.0-beta.2

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 (76) hide show
  1. package/dist/accessibility/apip.d.ts +66 -0
  2. package/dist/accessibility/apip.js +576 -0
  3. package/dist/accessibility/apip.js.map +1 -0
  4. package/dist/accessibility/catalog-info.d.ts +17 -0
  5. package/dist/accessibility/catalog-info.js +60 -0
  6. package/dist/accessibility/catalog-info.js.map +1 -0
  7. package/dist/accessibility/catalog.d.ts +53 -0
  8. package/dist/accessibility/catalog.js +68 -0
  9. package/dist/accessibility/catalog.js.map +1 -0
  10. package/dist/accessibility/index.d.ts +4 -0
  11. package/dist/accessibility/index.js +5 -0
  12. package/dist/accessibility/index.js.map +1 -0
  13. package/dist/accessibility/markup.d.ts +61 -0
  14. package/dist/accessibility/markup.js +484 -0
  15. package/dist/accessibility/markup.js.map +1 -0
  16. package/dist/dom/assignProps.d.ts +4 -0
  17. package/dist/dom/assignProps.js +9 -0
  18. package/dist/dom/assignProps.js.map +1 -0
  19. package/dist/dom/svelteMountController.d.ts +25 -0
  20. package/dist/dom/svelteMountController.js +131 -0
  21. package/dist/dom/svelteMountController.js.map +1 -0
  22. package/dist/dom/touchDrag.d.ts +10 -0
  23. package/dist/dom/touchDrag.js +141 -0
  24. package/dist/dom/touchDrag.js.map +1 -0
  25. package/dist/element-mapper/AttributeNameMapper.d.ts +66 -0
  26. package/dist/element-mapper/AttributeNameMapper.js +2 -0
  27. package/dist/element-mapper/AttributeNameMapper.js.map +1 -0
  28. package/dist/element-mapper/ElementNameMapper.d.ts +66 -0
  29. package/dist/element-mapper/ElementNameMapper.js +2 -0
  30. package/dist/element-mapper/ElementNameMapper.js.map +1 -0
  31. package/dist/element-mapper/Qti2xAttributeNameMapper.d.ts +27 -0
  32. package/dist/element-mapper/Qti2xAttributeNameMapper.js +38 -0
  33. package/dist/element-mapper/Qti2xAttributeNameMapper.js.map +1 -0
  34. package/dist/element-mapper/Qti2xElementNameMapper.d.ts +37 -0
  35. package/dist/element-mapper/Qti2xElementNameMapper.js +47 -0
  36. package/dist/element-mapper/Qti2xElementNameMapper.js.map +1 -0
  37. package/dist/element-mapper/Qti3AttributeNameMapper.d.ts +40 -0
  38. package/dist/element-mapper/Qti3AttributeNameMapper.js +87 -0
  39. package/dist/element-mapper/Qti3AttributeNameMapper.js.map +1 -0
  40. package/dist/element-mapper/Qti3ElementNameMapper.d.ts +14 -0
  41. package/dist/element-mapper/Qti3ElementNameMapper.js +39 -0
  42. package/dist/element-mapper/Qti3ElementNameMapper.js.map +1 -0
  43. package/dist/element-mapper/index.d.ts +8 -0
  44. package/dist/element-mapper/index.js +7 -0
  45. package/dist/element-mapper/index.js.map +1 -0
  46. package/dist/element-mapper/qti2-to-qti3.d.ts +36 -0
  47. package/dist/element-mapper/qti2-to-qti3.js +228 -0
  48. package/dist/element-mapper/qti2-to-qti3.js.map +1 -0
  49. package/dist/element-mapper/qti3-attribute-map.d.ts +8 -0
  50. package/dist/element-mapper/qti3-attribute-map.js +115 -0
  51. package/dist/element-mapper/qti3-attribute-map.js.map +1 -0
  52. package/dist/element-mapper/qti3-element-mappings.d.ts +538 -0
  53. package/dist/element-mapper/qti3-element-mappings.js +381 -0
  54. package/dist/element-mapper/qti3-element-mappings.js.map +1 -0
  55. package/dist/feedback/visibility.d.ts +12 -0
  56. package/dist/feedback/visibility.js +22 -0
  57. package/dist/feedback/visibility.js.map +1 -0
  58. package/dist/index.d.ts +17 -0
  59. package/dist/index.js +21 -0
  60. package/dist/index.js.map +1 -0
  61. package/dist/language/direction.d.ts +10 -0
  62. package/dist/language/direction.js +42 -0
  63. package/dist/language/direction.js.map +1 -0
  64. package/dist/parser-factory.d.ts +137 -0
  65. package/dist/parser-factory.js +146 -0
  66. package/dist/parser-factory.js.map +1 -0
  67. package/dist/version-detection/detectQtiVersion.d.ts +23 -0
  68. package/dist/version-detection/detectQtiVersion.js +129 -0
  69. package/dist/version-detection/detectQtiVersion.js.map +1 -0
  70. package/dist/version-detection/index.d.ts +2 -0
  71. package/dist/version-detection/index.js +2 -0
  72. package/dist/version-detection/index.js.map +1 -0
  73. package/dist/xml/attributes.d.ts +77 -0
  74. package/dist/xml/attributes.js +120 -0
  75. package/dist/xml/attributes.js.map +1 -0
  76. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apip.js","sourceRoot":"","sources":["../../src/accessibility/apip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAoB,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAGN,YAAY,EAGZ,SAAS,EACT,aAAa,GAEb,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,cAAc,GAAG,4DAA4D,CAAC;AAC3F,MAAM,CAAC,MAAM,cAAc,GAAG,qCAAqC,CAAC;AAkCpE,MAAM,MAAM,GAAG,QAAQ,CAAC;AACxB,MAAM,aAAa,GAAG,eAAe,CAAC;AACtC,MAAM,iBAAiB,GAAG,yCAAyC,CAAC;AACpE,MAAM,WAAW,GAAG,wBAAwB,CAAC;AAC7C,MAAM,oBAAoB,GAAG,iCAAiC,CAAC;AAC/D,+FAA+F;AAC/F,MAAM,mBAAmB,GAA2B;IACnD,WAAW,EAAE,KAAK;IAClB,qBAAqB,EAAE,QAAQ;CAC/B,CAAC;AACF,gEAAgE;AAChE,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IAClC,GAAG;IACH,GAAG;IACH,QAAQ;IACR,SAAS;IACT,KAAK;IACL,OAAO;IACP,UAAU;IACV,OAAO;IACP,SAAS;IACT,MAAM;IACN,OAAO;CACP,CAAC,CAAC;AACH,MAAM,aAAa,GAA0D;IAC5E,MAAM,EAAE,aAAa;IACrB,WAAW,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,E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C,KAAK,IAAI,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAmB;IAC5C,OAAO,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,KAAK,EAAwB,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,YAAY,CAAC,CAAC;AAC5G,CAAC;AAED,SAAS,UAAU,CAAC,MAAmB,EAAE,IAAY;IACpD,OAAO,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,SAAS,CAAC,OAAoB;IACtC,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC;IACrC,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AACxC,CAAC","sourcesContent":["/**\n * APIP accessibility\n *\n * QTI 2.x carries accessibility content as APIP 1.0: an `apip:apipAccessibility` element whose\n * `accessElement`s each link content elements, by `id`, to the supports that describe them. A\n * catalog is the same thing in QTI 3's terms, so an access element maps to one catalog by its\n * `identifier`, its supports to cards under the support names QTI 3 uses, as 1EdTech's\n * APIP-to-QTI 3 migration guide maps them:\n *\n * - `spoken`: one script card, the first of `textToSpeechPronunciationSSML` (as `<speak>`),\n * `textToSpeechPronunciation` and `spokenText`, the others kept as `ext:custom-` cards, and a\n * card per `audioFileInfo` recording, its `startTime` and `duration` the time range;\n * - `brailleText` as `braille`, `tactileFile` as `tactile`;\n * - `signing` as `sign-language` video, `ase` for ASL and `eng-US` for Signed English, with the\n * cues as the time range;\n * - `keyWordTranslation` as `keyword-translation`, one card per language;\n * - `guidance`'s `languageLearnerSupport` as `linguistic-guidance`.\n *\n * QTI 3 has no counterpart for the other supports, which the reader reports as unmapped;\n * `voiceType`, `voiceSpeed` and `supportOrder` are dropped, the last because document order is the\n * order.\n *\n * The writer maps the other way. A card APIP has no element for, a card past the one an element\n * holds, and a card missing what its element requires (a `tactile` recording without its text, an\n * audio file whose MIME type is unknown) are unwritten, and the result names their supports.\n * SSML elements APIP does not admit are unwrapped to their content. Plain-text APIP elements take\n * the card's text, its markup dropped.\n */\n\nimport { type HTMLElement, NodeType, parse, TextNode } from 'node-html-parser';\nimport {\n\ttype CatalogCard,\n\ttype CatalogCardPayload,\n\tclockSeconds,\n\ttype MediaFragmentRange,\n\ttype MediaKind,\n\tmediaKind,\n\tmediaMimeType,\n\ttype TextRange,\n} from './catalog.js';\n\nexport const APIP_NAMESPACE = 'http://www.imsglobal.org/xsd/apip/apipv1p0/imsapip_qtiv1p0';\nexport const SSML_NAMESPACE = 'http://www.w3.org/2001/10/synthesis';\n\n/** An APIP link from an access element to the content it describes. */\nexport interface ApipContentLink {\n\t/** The `id` of the content element, from `qtiLinkIdentifierRef`; empty when it names none. */\n\ttarget: string;\n\t/** The word or character range of the element's text, when the link has one. */\n\trange?: TextRange;\n\t/** The link names the element as an object (`objectLink`): an image, a media player. */\n\tobject?: boolean;\n}\n\nexport interface ApipAccessElement {\n\tidentifier: string;\n\tlinks: ApipContentLink[];\n\tcards: CatalogCard[];\n\t/** The supports QTI 3 has no counterpart for, by element name. */\n\tunmapped: string[];\n}\n\nexport type ApipAccessElementSource = Pick<ApipAccessElement, 'identifier' | 'links' | 'cards'>;\n\nexport interface ApipAccessibilityXml {\n\t/** The `apip:apipAccessibility` element, its namespaces declared on it; absent when nothing is written. */\n\txml?: string;\n\t/** The supports of the cards not written, by access element identifier. */\n\tunwritten: Map<string, string[]>;\n}\n\nexport interface ApipWriteOptions {\n\t/** The `id`s the document uses already, which the access elements and labels must not take. */\n\treservedIds?: Iterable<string>;\n}\n\nconst SPOKEN = 'spoken';\nconst SIGN_LANGUAGE = 'sign-language';\nconst TTS_PRONUNCIATION = 'ext:custom-text-to-speech-pronunciation';\nconst SPOKEN_TEXT = 'ext:custom-spoken-text';\nconst TACTILE_BRAILLE_TEXT = 'ext:custom-tactile-braille-text';\n/** The sign language a `signing` file is in: ASL, and Signed English as the guide codes it. */\nconst SIGN_FILE_LANGUAGES: Record<string, string> = {\n\tsignFileASL: 'ase',\n\tsignFileSignedEnglish: 'eng-US',\n};\n/** The SSML elements `textToSpeechPronunciationSSML` admits. */\nconst APIP_SSML_ELEMENTS = new Set([\n\t'p',\n\t's',\n\t'say-as',\n\t'phoneme',\n\t'sub',\n\t'voice',\n\t'emphasis',\n\t'break',\n\t'prosody',\n\t'mark',\n\t'audio',\n]);\nconst APIP_SUPPORTS: Record<string, (support: HTMLElement) => ApipSupport> = {\n\tspoken: spokenSupport,\n\tbrailleText: (support) => ({ cards: textCards('braille', textOf(support, 'brailleTextString')) }),\n\ttactileFile: (support) => {\n\t\tconst audio = firstChild(support, 'tactileAudioFile');\n\t\tconst payload = audio && audioPayload(audio);\n\t\treturn {\n\t\t\tcards: [\n\t\t\t\t...textCards('tactile', textOf(support, 'tactileAudioText')),\n\t\t\t\t...(payload ? [{ catalog: 'tactile', payload }] : []),\n\t\t\t\t...textCards(TACTILE_BRAILLE_TEXT, textOf(support, 'tactileBrailleText')),\n\t\t\t],\n\t\t};\n\t},\n\tsigning: (support) => {\n\t\tconst cards: CatalogCard[] = [];\n\t\tconst unmapped: string[] = [];\n\t\tfor (const signFile of allChildElements(support)) {\n\t\t\tconst language = SIGN_FILE_LANGUAGES[localName(signFile)];\n\t\t\tconst video = firstChild(signFile, 'videoFileInfo');\n\t\t\tconst payload = language && video ? videoPayload(video) : undefined;\n\t\t\tif (payload) cards.push({ catalog: SIGN_LANGUAGE, language, payload });\n\t\t\tif (!language) unmapped.push(localName(signFile));\n\t\t\telse if (firstChild(signFile, 'boneAnimationVideoFile')) unmapped.push('boneAnimationVideoFile');\n\t\t}\n\t\treturn { cards, unmapped };\n\t},\n\tkeyWordTranslation: (support) => ({\n\t\tcards: childElements(support, 'definitionId').flatMap((definition) => {\n\t\t\tconst language = definition.getAttribute('xml:lang')?.trim();\n\t\t\treturn textCards('keyword-translation', textOf(definition, 'textString')).map((card) =>\n\t\t\t\tlanguage ? { ...card, language } : card\n\t\t\t);\n\t\t}),\n\t}),\n\tguidance: (support) => {\n\t\tconst learner = firstChild(support, 'languageLearnerSupport');\n\t\treturn {\n\t\t\tcards: learner ? textCards('linguistic-guidance', textOf(learner, 'textString')) : [],\n\t\t\tunmapped: firstChild(support, 'cognitiveGuidanceSupport') ? ['cognitiveGuidanceSupport'] : [],\n\t\t};\n\t},\n};\n\ninterface ApipSupport {\n\tcards: CatalogCard[];\n\tunmapped?: string[];\n}\n\n/**\n * The APIP access elements a QTI 2.x document declares, in document order. A string is parsed\n * with its CDATA sections unwrapped; a parsed root must keep tag names as authored.\n */\nexport function readApipAccessElements(source: string | HTMLElement): ApipAccessElement[] {\n\tconst root =\n\t\ttypeof source === 'string'\n\t\t\t? parse(source.replace(/<!\\[CDATA\\[([\\s\\S]*?)\\]\\]>/g, '$1'), {\n\t\t\t\t\tlowerCaseTagName: false,\n\t\t\t\t\tcomment: false,\n\t\t\t\t})\n\t\t\t: source;\n\treturn root\n\t\t.querySelectorAll('*')\n\t\t.filter((element) => localName(element) === 'accessElement')\n\t\t.map((element) => {\n\t\t\tconst cards: CatalogCard[] = [];\n\t\t\tconst unmapped: string[] = [];\n\t\t\tfor (const info of childElements(element, 'relatedElementInfo')) {\n\t\t\t\tfor (const support of allChildElements(info)) {\n\t\t\t\t\tconst read = APIP_SUPPORTS[localName(support)];\n\t\t\t\t\tif (!read) {\n\t\t\t\t\t\tunmapped.push(localName(support));\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst mapped = read(support);\n\t\t\t\t\tcards.push(...mapped.cards);\n\t\t\t\t\tunmapped.push(...(mapped.unmapped ?? []));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tidentifier: element.getAttribute('identifier')?.trim() ?? '',\n\t\t\t\tlinks: childElements(element, 'contentLinkInfo').map(contentLink),\n\t\t\t\tcards,\n\t\t\t\tunmapped,\n\t\t\t};\n\t\t});\n}\n\n/** Write access elements as `apip:apipAccessibility`, for the end of an item or stimulus. */\nexport function writeApipAccessibility(\n\telements: ApipAccessElementSource[],\n\toptions: ApipWriteOptions = {}\n): ApipAccessibilityXml {\n\tconst ids = new IdAllocator(options.reservedIds);\n\tconst unwritten = new Map<string, string[]>();\n\tconst written: string[] = [];\n\tlet ssml = false;\n\tfor (const element of elements) {\n\t\tconst links = element.links.flatMap((link) => {\n\t\t\tconst xml = contentLinkXml(link);\n\t\t\treturn xml ? [xml] : [];\n\t\t});\n\t\tconst identifier = ids.take(ncName(element.identifier));\n\t\tconst label = () => ids.take(`${identifier}-${ids.next(identifier)}`);\n\t\tconst supports = links.length > 0 ? supportsXml(element.cards, label) : undefined;\n\t\tconst skipped = supports ? supports.unwritten : element.cards.map((card) => card.catalog);\n\t\tif (skipped.length > 0) unwritten.set(element.identifier, [...new Set(skipped)]);\n\t\tif (!supports || supports.xml.length === 0) continue;\n\t\tssml ||= supports.ssml;\n\t\twritten.push(\n\t\t\t`<apip:accessElement identifier=\"${escapeAttribute(identifier)}\">${links.join('')}` +\n\t\t\t\t`<apip:relatedElementInfo>${supports.xml.join('')}</apip:relatedElementInfo></apip:accessElement>`\n\t\t);\n\t}\n\tif (written.length === 0) return { unwritten };\n\tconst namespaces = `xmlns:apip=\"${APIP_NAMESPACE}\"${ssml ? ` xmlns:ssml=\"${SSML_NAMESPACE}\"` : ''}`;\n\treturn {\n\t\txml: `<apip:apipAccessibility ${namespaces}><apip:accessibilityInfo>${written.join('')}</apip:accessibilityInfo></apip:apipAccessibility>`,\n\t\tunwritten,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Reading\n// ---------------------------------------------------------------------------\n\nfunction spokenSupport(spoken: HTMLElement): ApipSupport {\n\tconst ssml = firstChild(spoken, 'textToSpeechPronunciationSSML');\n\t// The first script present is the spoken card; the ones it outranks keep their own names.\n\tconst scripts = [\n\t\t[SPOKEN, ssml && speakMarkup(ssml)],\n\t\t[TTS_PRONUNCIATION, textOf(spoken, 'textToSpeechPronunciation')],\n\t\t[SPOKEN_TEXT, textOf(spoken, 'spokenText')],\n\t].filter((script): script is [string, string] => Boolean(script[1]));\n\tconst recordings = childElements(spoken, 'audioFileInfo').flatMap((audio) => {\n\t\tconst payload = audioPayload(audio);\n\t\treturn payload ? [{ catalog: SPOKEN, payload }] : [];\n\t});\n\treturn {\n\t\tcards: [\n\t\t\t...scripts.map(([catalog, content], index) => ({\n\t\t\t\tcatalog: index === 0 ? SPOKEN : catalog,\n\t\t\t\tcontent,\n\t\t\t})),\n\t\t\t...recordings,\n\t\t],\n\t};\n}\n\n/** `textToSpeechPronunciationSSML` as a `<speak>` document, its elements without prefixes. */\nfunction speakMarkup(ssml: HTMLElement): string | undefined {\n\tconst markup = ssml.innerHTML\n\t\t.replace(/<(\\/?)[\\w.-]+:/g, '<$1')\n\t\t.replace(/\\s+xmlns(?::[\\w.-]+)?\\s*=\\s*(?:\"[^\"]*\"|'[^']*')/g, '')\n\t\t.replace(/\\s+/g, ' ')\n\t\t.trim();\n\tif (!markup) return undefined;\n\treturn /^<speak[\\s>]/.test(markup) ? markup : `<speak>${markup}</speak>`;\n}\n\nfunction audioPayload(info: HTMLElement): CatalogCardPayload | undefined {\n\tconst start = timeOf(info, 'startTime');\n\tconst duration = timeOf(info, 'duration');\n\tconst startSeconds = start ?? 0;\n\treturn filePayload(\n\t\tinfo,\n\t\t'audio',\n\t\tstart === undefined && duration === undefined\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\tstartSeconds,\n\t\t\t\t\t...(duration === undefined ? {} : { endSeconds: milliseconds(startSeconds + duration) }),\n\t\t\t\t}\n\t);\n}\n\nfunction videoPayload(info: HTMLElement): CatalogCardPayload | undefined {\n\tconst start = timeOf(info, 'startCue');\n\tconst end = timeOf(info, 'endCue');\n\treturn filePayload(\n\t\tinfo,\n\t\t'video',\n\t\tstart === undefined && end === undefined\n\t\t\t? undefined\n\t\t\t: { startSeconds: start ?? 0, ...(end === undefined ? {} : { endSeconds: end }) }\n\t);\n}\n\nfunction filePayload(\n\tinfo: HTMLElement,\n\tfallback: MediaKind,\n\tfragment: MediaFragmentRange | undefined\n): CatalogCardPayload | undefined {\n\tconst src = firstChild(info, 'fileHref')?.textContent.trim();\n\tif (!src) return undefined;\n\tconst type = info.getAttribute('mimeType')?.trim();\n\treturn {\n\t\tmedia: {\n\t\t\tversion: 1,\n\t\t\tid: src,\n\t\t\tkind: mediaKind(type, src, fallback),\n\t\t\tsources: [{ src, ...(type ? { type } : {}) }],\n\t\t},\n\t\t...(fragment ? { fragment } : {}),\n\t};\n}\n\n/** An `xs:time` child as seconds; its time zone, which a media offset has no use for, ignored. */\nfunction timeOf(parent: HTMLElement, name: string): number | undefined {\n\tconst value = firstChild(parent, name)\n\t\t?.textContent.trim()\n\t\t.replace(/(?:Z|[+-]\\d{2}:\\d{2})$/, '');\n\treturn value ? clockSeconds(value) : undefined;\n}\n\nfunction milliseconds(value: number): number {\n\treturn Math.round(value * 1000) / 1000;\n}\n\nfunction contentLink(link: HTMLElement): ApipContentLink {\n\tconst target = link.getAttribute('qtiLinkIdentifierRef')?.trim() ?? '';\n\tconst textLink = firstChild(link, 'textLink');\n\tconst word = textLink && firstChild(textLink, 'wordLink');\n\tconst character = textLink && firstChild(textLink, 'characterLink');\n\tconst characters = textLink && firstChild(textLink, 'characterStringLink');\n\tlet range: TextRange | undefined;\n\tif (word) {\n\t\trange = { unit: 'word', start: count(word), stop: count(word) };\n\t} else if (character) {\n\t\trange = { unit: 'character', start: count(character), stop: count(character) };\n\t} else if (characters) {\n\t\trange = {\n\t\t\tunit: 'character',\n\t\t\tstart: count(firstChild(characters, 'startCharacter')),\n\t\t\tstop: count(firstChild(characters, 'stopCharacter')),\n\t\t};\n\t}\n\treturn {\n\t\ttarget,\n\t\t...(range ? { range } : {}),\n\t\t...(firstChild(link, 'objectLink') ? { object: true } : {}),\n\t};\n}\n\n/** A link's word or character number; not a number when absent, so it locates nothing. */\nfunction count(element: HTMLElement | undefined): number {\n\treturn Number(element?.textContent.trim() || Number.NaN);\n}\n\n/** A text child as card content: its text, escaped as HTML. */\nfunction textOf(parent: HTMLElement, name: string): string | undefined {\n\tconst text = firstChild(parent, name)?.textContent.trim();\n\treturn text ? escapeText(text) : undefined;\n}\n\nfunction textCards(catalog: string, content: string | undefined): CatalogCard[] {\n\treturn content ? [{ catalog, content }] : [];\n}\n\n// ---------------------------------------------------------------------------\n// Writing\n// ---------------------------------------------------------------------------\n\ninterface SupportsXml {\n\t/** The `relatedElementInfo` children, in the order the reader lists their cards. */\n\txml: string[];\n\tunwritten: string[];\n\tssml: boolean;\n}\n\n/** Hands out unique NCName `id`s. */\nclass IdAllocator {\n\tprivate readonly used: Set<string>;\n\tprivate readonly counters = new Map<string, number>();\n\n\tconstructor(reserved: Iterable<string> = []) {\n\t\tthis.used = new Set(reserved);\n\t}\n\n\ttake(base: string): string {\n\t\tlet id = base;\n\t\tfor (let suffix = 2; this.used.has(id); suffix += 1) id = `${base}-${suffix}`;\n\t\tthis.used.add(id);\n\t\treturn id;\n\t}\n\n\t/** The next number in `base`'s sequence, from 1. */\n\tnext(base: string): number {\n\t\tconst value = (this.counters.get(base) ?? 0) + 1;\n\t\tthis.counters.set(base, value);\n\t\treturn value;\n\t}\n}\n\nfunction supportsXml(cards: CatalogCard[], label: () => string): SupportsXml {\n\tconst unwritten: string[] = [];\n\tconst byCatalog = (...catalogs: string[]) => cards.filter((card) => catalogs.includes(card.catalog));\n\tconst handled = new Set([\n\t\tSPOKEN,\n\t\tTTS_PRONUNCIATION,\n\t\tSPOKEN_TEXT,\n\t\t'braille',\n\t\t'tactile',\n\t\tTACTILE_BRAILLE_TEXT,\n\t\tSIGN_LANGUAGE,\n\t\t'keyword-translation',\n\t\t'linguistic-guidance',\n\t]);\n\tunwritten.push(...cards.filter((card) => !handled.has(card.catalog)).map((card) => card.catalog));\n\n\tconst xml: string[] = [];\n\tconst spoken = spokenXml(byCatalog(SPOKEN, TTS_PRONUNCIATION, SPOKEN_TEXT), label);\n\tunwritten.push(...spoken.unwritten);\n\tif (spoken.xml) xml.push(spoken.xml);\n\n\tfor (const card of byCatalog('braille')) {\n\t\tconst text = card.content === undefined ? undefined : plainText(card.content);\n\t\tif (text) xml.push(`<apip:brailleText>${labelled('brailleTextString', label(), text)}</apip:brailleText>`);\n\t\telse unwritten.push(card.catalog);\n\t}\n\n\tconst tactile = tactileXml(byCatalog('tactile', TACTILE_BRAILLE_TEXT), label);\n\tunwritten.push(...tactile.unwritten);\n\tif (tactile.xml) xml.push(tactile.xml);\n\n\tconst signFiles: Record<string, string[]> = { signFileASL: [], signFileSignedEnglish: [] };\n\tfor (const card of byCatalog(SIGN_LANGUAGE)) {\n\t\tconst element = Object.keys(SIGN_FILE_LANGUAGES).find(\n\t\t\t(name) => SIGN_FILE_LANGUAGES[name]?.toLowerCase() === card.language?.toLowerCase()\n\t\t);\n\t\tconst video = element && card.payload ? fileInfoXml('videoFileInfo', card.payload, label) : undefined;\n\t\tif (element && video) signFiles[element]?.push(`<apip:${element}>${video}</apip:${element}>`);\n\t\telse unwritten.push(card.catalog);\n\t}\n\tconst signing = Object.values(signFiles).flat();\n\tif (signing.length > 0) xml.push(`<apip:signing>${signing.join('')}</apip:signing>`);\n\n\tconst definitions = byCatalog('keyword-translation').flatMap((card) => {\n\t\tconst text = card.content === undefined ? undefined : plainText(card.content);\n\t\tif (!text || !card.language) {\n\t\t\tunwritten.push(card.catalog);\n\t\t\treturn [];\n\t\t}\n\t\treturn [\n\t\t\t`<apip:definitionId xml:lang=\"${escapeAttribute(card.language)}\">${labelled('textString', label(), text)}</apip:definitionId>`,\n\t\t];\n\t});\n\tif (definitions.length > 0) xml.push(`<apip:keyWordTranslation>${definitions.join('')}</apip:keyWordTranslation>`);\n\n\tconst [guidance, ...extraGuidance] = byCatalog('linguistic-guidance');\n\tconst guidanceText = guidance?.content === undefined ? undefined : plainText(guidance.content);\n\tif (guidance && guidanceText) {\n\t\txml.push(\n\t\t\t`<apip:guidance><apip:languageLearnerSupport><apip:supportOrder>1</apip:supportOrder>${labelled('textString', label(), guidanceText)}</apip:languageLearnerSupport></apip:guidance>`\n\t\t);\n\t} else if (guidance) {\n\t\tunwritten.push(guidance.catalog);\n\t}\n\tunwritten.push(...extraGuidance.map((card) => card.catalog));\n\n\treturn { xml, unwritten, ssml: spoken.ssml };\n}\n\n/**\n * One `spoken`: its recordings, then its scripts. A `<speak>` card is the SSML script; the\n * `ext:custom-` cards take their own elements, and a plain-text `spoken` card the first of\n * `textToSpeechPronunciation` and `spokenText` they leave free.\n */\nfunction spokenXml(\n\tcards: CatalogCard[],\n\tlabel: () => string\n): { xml?: string; unwritten: string[]; ssml: boolean } {\n\tconst unwritten: string[] = [];\n\tconst audio: string[] = [];\n\tconst slots: { ssml?: string; tts?: string; text?: string } = {};\n\tconst plain: CatalogCard[] = [];\n\tfor (const card of cards) {\n\t\tif (card.payload) {\n\t\t\tconst info = card.catalog === SPOKEN ? fileInfoXml('audioFileInfo', card.payload, label) : undefined;\n\t\t\tif (info) audio.push(info);\n\t\t\telse unwritten.push(card.catalog);\n\t\t\tcontinue;\n\t\t}\n\t\tconst content = card.content ?? '';\n\t\tconst ssml = card.catalog === SPOKEN && !slots.ssml ? ssmlScript(content) : undefined;\n\t\tconst text = plainText(content);\n\t\tif (ssml) slots.ssml = ssml;\n\t\telse if (card.catalog === TTS_PRONUNCIATION && !slots.tts && text) slots.tts = text;\n\t\telse if (card.catalog === SPOKEN_TEXT && !slots.text && text) slots.text = text;\n\t\telse if (card.catalog === SPOKEN && text) plain.push(card);\n\t\telse unwritten.push(card.catalog);\n\t}\n\tfor (const card of plain) {\n\t\tconst text = plainText(card.content ?? '');\n\t\tif (!slots.tts) slots.tts = text;\n\t\telse if (!slots.text) slots.text = text;\n\t\telse unwritten.push(card.catalog);\n\t}\n\tconst scripts = [\n\t\tslots.text && labelled('spokenText', label(), slots.text),\n\t\tslots.tts && labelled('textToSpeechPronunciation', label(), slots.tts),\n\t\tslots.ssml &&\n\t\t\t`<apip:textToSpeechPronunciationSSML>${slots.ssml}</apip:textToSpeechPronunciationSSML>`,\n\t].filter(Boolean);\n\tif (audio.length === 0 && scripts.length === 0) return { unwritten, ssml: false };\n\treturn {\n\t\txml: `<apip:spoken>${audio.join('')}${scripts.join('')}</apip:spoken>`,\n\t\tunwritten,\n\t\tssml: Boolean(slots.ssml),\n\t};\n}\n\n/** One `tactileFile`: it needs the `tactile` text, so the cards beside it go unwritten without one. */\nfunction tactileXml(cards: CatalogCard[], label: () => string): { xml?: string; unwritten: string[] } {\n\tconst unwritten: string[] = [];\n\tlet text: string | undefined;\n\tlet audio: string | undefined;\n\tlet braille: string | undefined;\n\tfor (const card of cards) {\n\t\tconst value = card.content === undefined ? undefined : plainText(card.content);\n\t\tif (card.catalog === TACTILE_BRAILLE_TEXT && value && !braille) braille = value;\n\t\telse if (card.catalog === 'tactile' && card.payload && !audio) {\n\t\t\taudio = fileInfoXml('tactileAudioFile', card.payload, label);\n\t\t\tif (!audio) unwritten.push(card.catalog);\n\t\t} else if (card.catalog === 'tactile' && value && !text) text = value;\n\t\telse unwritten.push(card.catalog);\n\t}\n\tif (!text) return { unwritten: cards.map((card) => card.catalog) };\n\treturn {\n\t\txml:\n\t\t\t`<apip:tactileFile>${audio ?? ''}${labelled('tactileAudioText', label(), text)}` +\n\t\t\t`${braille ? labelled('tactileBrailleText', label(), braille) : ''}</apip:tactileFile>`,\n\t\tunwritten,\n\t};\n}\n\n/** An `audioFileInfo` or `videoFileInfo` for a payload's first source whose MIME type is known. */\nfunction fileInfoXml(name: string, payload: CatalogCardPayload, label: () => string): string | undefined {\n\tconst video = name === 'videoFileInfo';\n\tconst source = payload.media.sources\n\t\t.map((candidate) => ({ ...candidate, mimeType: mediaMimeType(candidate) }))\n\t\t.find((candidate) => candidate.src && candidate.mimeType);\n\tif (!source) return undefined;\n\tconst { fragment } = payload;\n\tlet times = '';\n\tif (fragment && video) {\n\t\ttimes =\n\t\t\t`<apip:startCue>${xsTime(fragment.startSeconds)}</apip:startCue>` +\n\t\t\t(fragment.endSeconds === undefined ? '' : `<apip:endCue>${xsTime(fragment.endSeconds)}</apip:endCue>`);\n\t} else if (fragment) {\n\t\ttimes =\n\t\t\t`<apip:startTime>${xsTime(fragment.startSeconds)}</apip:startTime>` +\n\t\t\t(fragment.endSeconds === undefined\n\t\t\t\t? ''\n\t\t\t\t: `<apip:duration>${xsTime(fragment.endSeconds - fragment.startSeconds)}</apip:duration>`);\n\t}\n\treturn (\n\t\t`<apip:${name} contentLinkIdentifier=\"${escapeAttribute(label())}\" mimeType=\"${escapeAttribute(source.mimeType as string)}\">` +\n\t\t`<apip:fileHref>${escapeText(source.src)}</apip:fileHref>${times}</apip:${name}>`\n\t);\n}\n\n\n/** Seconds as an `xs:time`, to the millisecond. */\nfunction xsTime(seconds: number): string {\n\tconst total = Math.max(0, Math.round(seconds * 1000));\n\tconst pad = (value: number) => String(value).padStart(2, '0');\n\tconst fraction = total % 1000;\n\tconst clock = `${pad(Math.floor(total / 3_600_000))}:${pad(Math.floor(total / 60_000) % 60)}:${pad(Math.floor(total / 1000) % 60)}`;\n\treturn fraction === 0 ? clock : `${clock}.${String(fraction).padStart(3, '0').replace(/0+$/, '')}`;\n}\n\nfunction contentLinkXml(link: ApipContentLink): string | undefined {\n\tif (!link.target) return undefined;\n\tconst { range } = link;\n\tlet body: string;\n\tif (link.object) {\n\t\tbody = '<apip:objectLink/>';\n\t} else if (!range) {\n\t\tbody = '<apip:textLink><apip:fullString/></apip:textLink>';\n\t} else if (!Number.isInteger(range.start) || !Number.isInteger(range.stop)) {\n\t\treturn undefined;\n\t} else if (range.unit === 'character' && range.start !== range.stop) {\n\t\tbody = `<apip:textLink><apip:characterStringLink><apip:startCharacter>${range.start}</apip:startCharacter><apip:stopCharacter>${range.stop}</apip:stopCharacter></apip:characterStringLink></apip:textLink>`;\n\t} else if (range.start === range.stop) {\n\t\tconst element = range.unit === 'word' ? 'wordLink' : 'characterLink';\n\t\tbody = `<apip:textLink><apip:${element}>${range.start}</apip:${element}></apip:textLink>`;\n\t} else {\n\t\t// APIP links one word, never a run of them.\n\t\treturn undefined;\n\t}\n\treturn `<apip:contentLinkInfo qtiLinkIdentifierRef=\"${escapeAttribute(link.target)}\">${body}</apip:contentLinkInfo>`;\n}\n\n/** A `<speak>` card's content as APIP SSML, prefixed, or `undefined` when it is not SSML. */\nfunction ssmlScript(content: string): string | undefined {\n\tif (!/^\\s*<(?:[\\w.-]+:)?speak[\\s>/]/.test(content)) return undefined;\n\tconst root = parse(content, { lowerCaseTagName: false, comment: false });\n\tconst speak = allChildElements(root).find((element) => localName(element) === 'speak');\n\tconst script = speak ? speak.childNodes.map(ssmlNode).join('').trim() : '';\n\treturn script || undefined;\n}\n\nfunction ssmlNode(node: HTMLElement['childNodes'][number]): string {\n\tif (node instanceof TextNode) return escapeText(node.text);\n\tif (node.nodeType !== NodeType.ELEMENT_NODE) return '';\n\tconst element = node as HTMLElement;\n\tconst children = element.childNodes.map(ssmlNode).join('');\n\tconst name = localName(element);\n\tif (!APIP_SSML_ELEMENTS.has(name)) return children;\n\tconst attributes = Object.entries(element.attributes)\n\t\t.filter(([attribute]) => attribute !== 'xmlns' && !attribute.startsWith('xmlns:'))\n\t\t.map(([attribute, value]) => ` ${attribute}=\"${escapeAttribute(value)}\"`)\n\t\t.join('');\n\treturn children ? `<ssml:${name}${attributes}>${children}</ssml:${name}>` : `<ssml:${name}${attributes}/>`;\n}\n\n/** Card content as the text a plain-text APIP element holds. */\nfunction plainText(content: string): string {\n\treturn parse(content).textContent.trim();\n}\n\nfunction labelled(name: string, identifier: string, text: string): string {\n\treturn `<apip:${name} contentLinkIdentifier=\"${escapeAttribute(identifier)}\">${escapeText(text)}</apip:${name}>`;\n}\n\n/** `value` as an `xs:ID`: characters an NCName cannot hold become `-`, and a leading non-letter gains `_`. */\nfunction ncName(value: string): string {\n\tconst name = value.trim().replace(/[^\\w.-]/g, '-');\n\treturn /^[A-Za-z_]/.test(name) ? name : `_${name}`;\n}\n\n// ---------------------------------------------------------------------------\n// Shared\n// ---------------------------------------------------------------------------\n\nfunction escapeText(text: string): string {\n\treturn text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n}\n\nfunction escapeAttribute(value: string): string {\n\treturn escapeText(value).replace(/\"/g, '&quot;');\n}\n\nfunction childElements(parent: HTMLElement, name: string): HTMLElement[] {\n\treturn allChildElements(parent).filter((child) => localName(child) === name);\n}\n\nfunction allChildElements(parent: HTMLElement): HTMLElement[] {\n\treturn parent.childNodes.filter((child): child is HTMLElement => child.nodeType === NodeType.ELEMENT_NODE);\n}\n\nfunction firstChild(parent: HTMLElement, name: string): HTMLElement | undefined {\n\treturn childElements(parent, name)[0];\n}\n\nfunction localName(element: HTMLElement): string {\n\tconst raw = element.rawTagName ?? '';\n\treturn raw.slice(raw.indexOf(':') + 1);\n}\n"]}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * QTI 3 catalog info
3
+ *
4
+ * QTI 3.0 carries catalogs natively as `qti-catalog-info`, the shape the cards already have: each
5
+ * catalog becomes a `qti-catalog` by its identifier, each card a `qti-card` with its support and
6
+ * `xml:lang`. HTML content goes in `qti-html-content`; a `<speak>` script is put in the SSML
7
+ * namespace, where QTI 3 admits it. A media payload becomes one `qti-file-href` per source, with
8
+ * the MIME type QTI 3 requires (`application/octet-stream` when unknown) and its time range as a
9
+ * media fragment. A card with neither body, and a catalog left without a card, are not written.
10
+ */
11
+ import { type AccessibilityCatalog } from './catalog.js';
12
+ export interface QtiCatalogInfoOptions {
13
+ /** Card HTML as the document's XML. Identity by default; SSML scripts bypass it. */
14
+ html?: (content: string) => string;
15
+ }
16
+ /** The `qti-catalog-info` element for `catalogs`, or `''` when none has a card to write. */
17
+ export declare function writeQtiCatalogInfo(catalogs: readonly AccessibilityCatalog[], options?: QtiCatalogInfoOptions): string;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * QTI 3 catalog info
3
+ *
4
+ * QTI 3.0 carries catalogs natively as `qti-catalog-info`, the shape the cards already have: each
5
+ * catalog becomes a `qti-catalog` by its identifier, each card a `qti-card` with its support and
6
+ * `xml:lang`. HTML content goes in `qti-html-content`; a `<speak>` script is put in the SSML
7
+ * namespace, where QTI 3 admits it. A media payload becomes one `qti-file-href` per source, with
8
+ * the MIME type QTI 3 requires (`application/octet-stream` when unknown) and its time range as a
9
+ * media fragment. A card with neither body, and a catalog left without a card, are not written.
10
+ */
11
+ import { SSML_NAMESPACE } from './apip.js';
12
+ import { mediaMimeType } from './catalog.js';
13
+ const SPEAK = /^\s*<speak(?=[\s>/])/;
14
+ /** The `qti-catalog-info` element for `catalogs`, or `''` when none has a card to write. */
15
+ export function writeQtiCatalogInfo(catalogs, options = {}) {
16
+ const html = options.html ?? ((content) => content);
17
+ const written = catalogs.flatMap(({ identifier, cards }) => {
18
+ const xml = cards.flatMap((card) => cardXml(card, html) ?? []);
19
+ return xml.length > 0 ? [`<qti-catalog id="${escapeAttribute(identifier)}">${xml.join('')}</qti-catalog>`] : [];
20
+ });
21
+ return written.length > 0 ? `<qti-catalog-info>${written.join('')}</qti-catalog-info>` : '';
22
+ }
23
+ function cardXml(card, html) {
24
+ const body = card.content?.trim() ? htmlContent(card.content, html) : fileHrefs(card);
25
+ if (!body)
26
+ return undefined;
27
+ const lang = card.language ? ` xml:lang="${escapeAttribute(card.language)}"` : '';
28
+ return `<qti-card support="${escapeAttribute(card.catalog)}"${lang}>${body}</qti-card>`;
29
+ }
30
+ function htmlContent(content, html) {
31
+ if (!SPEAK.test(content))
32
+ return `<qti-html-content>${html(content)}</qti-html-content>`;
33
+ const ssml = /^\s*<speak[^>]*\sxmlns\s*=/.test(content)
34
+ ? content
35
+ : content.replace(SPEAK, (open) => `${open} xmlns="${SSML_NAMESPACE}"`);
36
+ return `<qti-html-content>${ssml}</qti-html-content>`;
37
+ }
38
+ function fileHrefs({ payload }) {
39
+ if (!payload)
40
+ return undefined;
41
+ const { fragment } = payload;
42
+ const range = fragment
43
+ ? `#t=${fragment.startSeconds}${fragment.endSeconds === undefined ? '' : `,${fragment.endSeconds}`}`
44
+ : '';
45
+ const files = payload.media.sources
46
+ .filter((source) => source.src.trim())
47
+ .map((source) => {
48
+ const type = mediaMimeType(source) ?? 'application/octet-stream';
49
+ const href = source.src.includes('#') ? source.src : `${source.src}${range}`;
50
+ return `<qti-file-href mime-type="${escapeAttribute(type)}">${escapeText(href)}</qti-file-href>`;
51
+ });
52
+ return files.length > 0 ? files.join('') : undefined;
53
+ }
54
+ function escapeText(text) {
55
+ return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
56
+ }
57
+ function escapeAttribute(value) {
58
+ return escapeText(value).replace(/"/g, '&quot;');
59
+ }
60
+ //# sourceMappingURL=catalog-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog-info.js","sourceRoot":"","sources":["../../src/accessibility/catalog-info.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAA+C,aAAa,EAAE,MAAM,cAAc,CAAC;AAO1F,MAAM,KAAK,GAAG,sBAAsB,CAAC;AAErC,4FAA4F;AAC5F,MAAM,UAAU,mBAAmB,CAClC,QAAyC,EACzC,UAAiC,EAAE;IAEnC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,OAAe,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE;QAC1D,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAC/D,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAA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AAChF,CAAC;AAED,SAAS,eAAe,CAAC,KAAa;IACrC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAClD,CAAC","sourcesContent":["/**\n * QTI 3 catalog info\n *\n * QTI 3.0 carries catalogs natively as `qti-catalog-info`, the shape the cards already have: each\n * catalog becomes a `qti-catalog` by its identifier, each card a `qti-card` with its support and\n * `xml:lang`. HTML content goes in `qti-html-content`; a `<speak>` script is put in the SSML\n * namespace, where QTI 3 admits it. A media payload becomes one `qti-file-href` per source, with\n * the MIME type QTI 3 requires (`application/octet-stream` when unknown) and its time range as a\n * media fragment. A card with neither body, and a catalog left without a card, are not written.\n */\n\nimport { SSML_NAMESPACE } from './apip.js';\nimport { type AccessibilityCatalog, type CatalogCard, mediaMimeType } from './catalog.js';\n\nexport interface QtiCatalogInfoOptions {\n\t/** Card HTML as the document's XML. Identity by default; SSML scripts bypass it. */\n\thtml?: (content: string) => string;\n}\n\nconst SPEAK = /^\\s*<speak(?=[\\s>/])/;\n\n/** The `qti-catalog-info` element for `catalogs`, or `''` when none has a card to write. */\nexport function writeQtiCatalogInfo(\n\tcatalogs: readonly AccessibilityCatalog[],\n\toptions: QtiCatalogInfoOptions = {},\n): string {\n\tconst html = options.html ?? ((content: string) => content);\n\tconst written = catalogs.flatMap(({ identifier, cards }) => {\n\t\tconst xml = cards.flatMap((card) => cardXml(card, html) ?? []);\n\t\treturn xml.length > 0 ? [`<qti-catalog id=\"${escapeAttribute(identifier)}\">${xml.join('')}</qti-catalog>`] : [];\n\t});\n\treturn written.length > 0 ? `<qti-catalog-info>${written.join('')}</qti-catalog-info>` : '';\n}\n\nfunction cardXml(card: CatalogCard, html: (content: string) => string): string | undefined {\n\tconst body = card.content?.trim() ? htmlContent(card.content, html) : fileHrefs(card);\n\tif (!body) return undefined;\n\tconst lang = card.language ? ` xml:lang=\"${escapeAttribute(card.language)}\"` : '';\n\treturn `<qti-card support=\"${escapeAttribute(card.catalog)}\"${lang}>${body}</qti-card>`;\n}\n\nfunction htmlContent(content: string, html: (content: string) => string): string {\n\tif (!SPEAK.test(content)) return `<qti-html-content>${html(content)}</qti-html-content>`;\n\tconst ssml = /^\\s*<speak[^>]*\\sxmlns\\s*=/.test(content)\n\t\t? content\n\t\t: content.replace(SPEAK, (open) => `${open} xmlns=\"${SSML_NAMESPACE}\"`);\n\treturn `<qti-html-content>${ssml}</qti-html-content>`;\n}\n\nfunction fileHrefs({ payload }: CatalogCard): string | undefined {\n\tif (!payload) return undefined;\n\tconst { fragment } = payload;\n\tconst range = fragment\n\t\t? `#t=${fragment.startSeconds}${fragment.endSeconds === undefined ? '' : `,${fragment.endSeconds}`}`\n\t\t: '';\n\tconst files = payload.media.sources\n\t\t.filter((source) => source.src.trim())\n\t\t.map((source) => {\n\t\t\tconst type = mediaMimeType(source) ?? 'application/octet-stream';\n\t\t\tconst href = source.src.includes('#') ? source.src : `${source.src}${range}`;\n\t\t\treturn `<qti-file-href mime-type=\"${escapeAttribute(type)}\">${escapeText(href)}</qti-file-href>`;\n\t\t});\n\treturn files.length > 0 ? files.join('') : undefined;\n}\n\nfunction escapeText(text: string): string {\n\treturn text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n}\n\nfunction escapeAttribute(value: string): string {\n\treturn escapeText(value).replace(/\"/g, '&quot;');\n}\n"]}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Accessibility catalog cards
3
+ *
4
+ * The card shape pie-players resolves: a catalog per identifier, a card per support and language,
5
+ * its body either HTML `content` or a media `payload`. Support names are QTI 3's.
6
+ */
7
+ export type MediaKind = 'image' | 'audio' | 'video' | 'other';
8
+ /** One playable encoding of a media asset. */
9
+ export interface MediaSource {
10
+ src: string;
11
+ /** MIME type, omitted when the source does not declare one. */
12
+ type?: string;
13
+ }
14
+ export interface MediaAssetRef {
15
+ version: 1;
16
+ id: string;
17
+ kind: MediaKind;
18
+ sources: MediaSource[];
19
+ }
20
+ /** A time slice of a media asset, from a QTI 3 media fragment (`#t=2,5`). */
21
+ export interface MediaFragmentRange {
22
+ startSeconds: number;
23
+ endSeconds?: number;
24
+ }
25
+ /** The structured form of a card: a recording for `spoken`, a video for `sign-language`. */
26
+ export interface CatalogCardPayload {
27
+ media: MediaAssetRef;
28
+ fragment?: MediaFragmentRange;
29
+ }
30
+ /** One alternate representation of a content node. Exactly one of `content` and `payload`. */
31
+ export interface CatalogCard {
32
+ /** The QTI `support`, e.g. `spoken`, `sign-language`, `glossary-on-screen`. */
33
+ catalog: string;
34
+ language?: string;
35
+ content?: string;
36
+ payload?: CatalogCardPayload;
37
+ }
38
+ export interface AccessibilityCatalog {
39
+ identifier: string;
40
+ cards: CatalogCard[];
41
+ }
42
+ /** A word or character range of an element's text, counted from 1, both ends included. */
43
+ export interface TextRange {
44
+ unit: 'word' | 'character';
45
+ start: number;
46
+ stop: number;
47
+ }
48
+ /** A media source's MIME type: as declared, else from its extension; `undefined` when unknown. */
49
+ export declare function mediaMimeType(source: MediaSource): string | undefined;
50
+ /** A media asset's kind, from its MIME type, else its extension, else `fallback`. */
51
+ export declare function mediaKind(type: string | undefined, src: string, fallback: MediaKind): MediaKind;
52
+ /** A clock value (`90`, `1:30`, `00:01:30.5`) as seconds; `undefined` when it is not one. */
53
+ export declare function clockSeconds(value: string): number | undefined;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Accessibility catalog cards
3
+ *
4
+ * The card shape pie-players resolves: a catalog per identifier, a card per support and language,
5
+ * its body either HTML `content` or a media `payload`. Support names are QTI 3's.
6
+ */
7
+ const EXTENSION_KINDS = {
8
+ aac: 'audio',
9
+ m4a: 'audio',
10
+ mp3: 'audio',
11
+ oga: 'audio',
12
+ ogg: 'audio',
13
+ wav: 'audio',
14
+ m4v: 'video',
15
+ mov: 'video',
16
+ mp4: 'video',
17
+ ogv: 'video',
18
+ webm: 'video',
19
+ gif: 'image',
20
+ jpeg: 'image',
21
+ jpg: 'image',
22
+ png: 'image',
23
+ svg: 'image',
24
+ webp: 'image',
25
+ };
26
+ const MIME_TYPES = {
27
+ aac: 'audio/aac',
28
+ m4a: 'audio/mp4',
29
+ mp3: 'audio/mpeg',
30
+ oga: 'audio/ogg',
31
+ ogg: 'audio/ogg',
32
+ wav: 'audio/wav',
33
+ m4v: 'video/x-m4v',
34
+ mov: 'video/quicktime',
35
+ mp4: 'video/mp4',
36
+ ogv: 'video/ogg',
37
+ webm: 'video/webm',
38
+ gif: 'image/gif',
39
+ jpeg: 'image/jpeg',
40
+ jpg: 'image/jpeg',
41
+ png: 'image/png',
42
+ svg: 'image/svg+xml',
43
+ webp: 'image/webp',
44
+ };
45
+ /** A media source's MIME type: as declared, else from its extension; `undefined` when unknown. */
46
+ export function mediaMimeType(source) {
47
+ const declared = source.type?.trim();
48
+ if (declared)
49
+ return declared;
50
+ const extension = /\.([a-z0-9]+)(?:[?#].*)?$/i.exec(source.src)?.[1]?.toLowerCase();
51
+ return extension ? MIME_TYPES[extension] : undefined;
52
+ }
53
+ /** A media asset's kind, from its MIME type, else its extension, else `fallback`. */
54
+ export function mediaKind(type, src, fallback) {
55
+ const prefix = type?.split('/')[0]?.toLowerCase();
56
+ if (prefix === 'image' || prefix === 'audio' || prefix === 'video')
57
+ return prefix;
58
+ const extension = /\.([a-z0-9]+)$/i.exec(src)?.[1]?.toLowerCase();
59
+ return (extension ? EXTENSION_KINDS[extension] : undefined) ?? fallback;
60
+ }
61
+ /** A clock value (`90`, `1:30`, `00:01:30.5`) as seconds; `undefined` when it is not one. */
62
+ export function clockSeconds(value) {
63
+ const parts = value.split(':').map(Number);
64
+ if (parts.length > 3 || parts.some((part) => !Number.isFinite(part)))
65
+ return undefined;
66
+ return parts.reduce((total, part) => total * 60 + part, 0);
67
+ }
68
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/accessibility/catalog.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAm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CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,SAAS,CAAC,IAAwB,EAAE,GAAW,EAAE,QAAmB;IACnF,MAAM,MAAM,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;IAClD,IAAI,MAAM,KAAK,OAAO,IAAI,MAAM,KAAK,OAAO,IAAI,MAAM,KAAK,OAAO;QAAE,OAAO,MAAM,CAAC;IAClF,MAAM,SAAS,GAAG,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;IAClE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,QAAQ,CAAC;AACzE,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,YAAY,CAAC,KAAa;IACzC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACvF,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["/**\n * Accessibility catalog cards\n *\n * The card shape pie-players resolves: a catalog per identifier, a card per support and language,\n * its body either HTML `content` or a media `payload`. Support names are QTI 3's.\n */\n\nexport type MediaKind = 'image' | 'audio' | 'video' | 'other';\n\n/** One playable encoding of a media asset. */\nexport interface MediaSource {\n\tsrc: string;\n\t/** MIME type, omitted when the source does not declare one. */\n\ttype?: string;\n}\n\nexport interface MediaAssetRef {\n\tversion: 1;\n\tid: string;\n\tkind: MediaKind;\n\tsources: MediaSource[];\n}\n\n/** A time slice of a media asset, from a QTI 3 media fragment (`#t=2,5`). */\nexport interface MediaFragmentRange {\n\tstartSeconds: number;\n\tendSeconds?: number;\n}\n\n/** The structured form of a card: a recording for `spoken`, a video for `sign-language`. */\nexport interface CatalogCardPayload {\n\tmedia: MediaAssetRef;\n\tfragment?: MediaFragmentRange;\n}\n\n/** One alternate representation of a content node. Exactly one of `content` and `payload`. */\nexport interface CatalogCard {\n\t/** The QTI `support`, e.g. `spoken`, `sign-language`, `glossary-on-screen`. */\n\tcatalog: string;\n\tlanguage?: string;\n\tcontent?: string;\n\tpayload?: CatalogCardPayload;\n}\n\nexport interface AccessibilityCatalog {\n\tidentifier: string;\n\tcards: CatalogCard[];\n}\n\n/** A word or character range of an element's text, counted from 1, both ends included. */\nexport interface TextRange {\n\tunit: 'word' | 'character';\n\tstart: number;\n\tstop: number;\n}\n\nconst EXTENSION_KINDS: Record<string, MediaKind> = {\n\taac: 'audio',\n\tm4a: 'audio',\n\tmp3: 'audio',\n\toga: 'audio',\n\togg: 'audio',\n\twav: 'audio',\n\tm4v: 'video',\n\tmov: 'video',\n\tmp4: 'video',\n\togv: 'video',\n\twebm: 'video',\n\tgif: 'image',\n\tjpeg: 'image',\n\tjpg: 'image',\n\tpng: 'image',\n\tsvg: 'image',\n\twebp: 'image',\n};\n\nconst MIME_TYPES: Record<string, string> = {\n\taac: 'audio/aac',\n\tm4a: 'audio/mp4',\n\tmp3: 'audio/mpeg',\n\toga: 'audio/ogg',\n\togg: 'audio/ogg',\n\twav: 'audio/wav',\n\tm4v: 'video/x-m4v',\n\tmov: 'video/quicktime',\n\tmp4: 'video/mp4',\n\togv: 'video/ogg',\n\twebm: 'video/webm',\n\tgif: 'image/gif',\n\tjpeg: 'image/jpeg',\n\tjpg: 'image/jpeg',\n\tpng: 'image/png',\n\tsvg: 'image/svg+xml',\n\twebp: 'image/webp',\n};\n\n/** A media source's MIME type: as declared, else from its extension; `undefined` when unknown. */\nexport function mediaMimeType(source: MediaSource): string | undefined {\n\tconst declared = source.type?.trim();\n\tif (declared) return declared;\n\tconst extension = /\\.([a-z0-9]+)(?:[?#].*)?$/i.exec(source.src)?.[1]?.toLowerCase();\n\treturn extension ? MIME_TYPES[extension] : undefined;\n}\n\n/** A media asset's kind, from its MIME type, else its extension, else `fallback`. */\nexport function mediaKind(type: string | undefined, src: string, fallback: MediaKind): MediaKind {\n\tconst prefix = type?.split('/')[0]?.toLowerCase();\n\tif (prefix === 'image' || prefix === 'audio' || prefix === 'video') return prefix;\n\tconst extension = /\\.([a-z0-9]+)$/i.exec(src)?.[1]?.toLowerCase();\n\treturn (extension ? EXTENSION_KINDS[extension] : undefined) ?? fallback;\n}\n\n/** A clock value (`90`, `1:30`, `00:01:30.5`) as seconds; `undefined` when it is not one. */\nexport function clockSeconds(value: string): number | undefined {\n\tconst parts = value.split(':').map(Number);\n\tif (parts.length > 3 || parts.some((part) => !Number.isFinite(part))) return undefined;\n\treturn parts.reduce((total, part) => total * 60 + part, 0);\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export { APIP_NAMESPACE, type ApipAccessElement, type ApipAccessElementSource, type ApipAccessibilityXml, type ApipContentLink, type ApipWriteOptions, readApipAccessElements, SSML_NAMESPACE, writeApipAccessibility, } from './apip.js';
2
+ export { type AccessibilityCatalog, type CatalogCard, type CatalogCardPayload, clockSeconds, type MediaAssetRef, type MediaFragmentRange, type MediaKind, type MediaSource, mediaKind, mediaMimeType, type TextRange, } from './catalog.js';
3
+ export { type QtiCatalogInfoOptions, writeQtiCatalogInfo } from './catalog-info.js';
4
+ export { type ContentLink, escapeText, HIDING_STYLES, type PreparedMarkup, type PrepareContentMarkupOptions, prepareContentMarkup, SSML_NAMESPACES, } from './markup.js';
@@ -0,0 +1,5 @@
1
+ export { APIP_NAMESPACE, readApipAccessElements, SSML_NAMESPACE, writeApipAccessibility, } from './apip.js';
2
+ export { clockSeconds, mediaKind, mediaMimeType, } from './catalog.js';
3
+ export { writeQtiCatalogInfo } from './catalog-info.js';
4
+ export { escapeText, HIDING_STYLES, prepareContentMarkup, SSML_NAMESPACES, } from './markup.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/accessibility/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EAMd,sBAAsB,EACtB,cAAc,EACd,sBAAsB,GACtB,MAAM,WAAW,CAAC;AACnB,OAAO,EAIN,YAAY,EAKZ,SAAS,EACT,aAAa,GAEb,MAAM,cAAc,CAAC;AACtB,OAAO,EAA8B,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAEN,UAAU,EACV,aAAa,EAGb,oBAAoB,EACpB,eAAe,GACf,MAAM,aAAa,CAAC","sourcesContent":["export {\n\tAPIP_NAMESPACE,\n\ttype ApipAccessElement,\n\ttype ApipAccessElementSource,\n\ttype ApipAccessibilityXml,\n\ttype ApipContentLink,\n\ttype ApipWriteOptions,\n\treadApipAccessElements,\n\tSSML_NAMESPACE,\n\twriteApipAccessibility,\n} from './apip.js';\nexport {\n\ttype AccessibilityCatalog,\n\ttype CatalogCard,\n\ttype CatalogCardPayload,\n\tclockSeconds,\n\ttype MediaAssetRef,\n\ttype MediaFragmentRange,\n\ttype MediaKind,\n\ttype MediaSource,\n\tmediaKind,\n\tmediaMimeType,\n\ttype TextRange,\n} from './catalog.js';\nexport { type QtiCatalogInfoOptions, writeQtiCatalogInfo } from './catalog-info.js';\nexport {\n\ttype ContentLink,\n\tescapeText,\n\tHIDING_STYLES,\n\ttype PreparedMarkup,\n\ttype PrepareContentMarkupOptions,\n\tprepareContentMarkup,\n\tSSML_NAMESPACES,\n} from './markup.js';\n"]}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Accessibility markup
3
+ *
4
+ * The edits that prepare a QTI document's content for PIE conversion and for delivery, so what QTI
5
+ * voices, hides or suppresses stays so for the PIE read-aloud tools. Each content root (`itemBody`,
6
+ * `modalFeedback`, `stimulusBody`, in QTI 2 or QTI 3 spelling) is read as a token stream into an
7
+ * element tree, and rebuilt with the edits applied; markup outside the roots, comments and
8
+ * processing instructions are left as authored. CDATA is edited like the markup around it, since
9
+ * the HTML it wraps is what converts.
10
+ *
11
+ * 1. `qti-hidden` and `qti-visually-hidden` get the inline style the class stands for, since the
12
+ * shared-vocabulary stylesheet has no URL a PIE player can load and players strip `<style>`.
13
+ * Delivery ships that stylesheet and turns this edit off with `hidingStyles: false`.
14
+ * 2. `data-qti-suppress-tts` is restated as `data-tts-suppress`, the only spelling PIE reads.
15
+ * 3. An element with `data-ssml` gets a generated `data-catalog-idref`, and the SSML becomes a
16
+ * `spoken` card under it; an element that already names a catalog adds the card to that one.
17
+ * 4. Each APIP content link docks its access element's idref: on the element whose `id` it names,
18
+ * or on a span around the word or character range its `textLink` counts. Words are counted
19
+ * from 1 over the element's text split on whitespace, punctuation kept with its word, as
20
+ * 1EdTech's APIP-to-QTI 3 migration guide counts them; characters from 1 with whitespace runs
21
+ * collapsed. A range that crosses markup or overlaps another range is not docked.
22
+ * 5. Inline SSML elements are unwrapped with their text kept, and their nearest enclosing element
23
+ * gets a `spoken` card holding its content as SSML: the shape `SSMLExtractor` in pie-players
24
+ * produces from a `<speak>` element, so both reach `TTSService` alike.
25
+ * 6. `xml:lang` is restated as `lang`, the attribute HTML reads for the language of content, and
26
+ * gets the `dir` of that language where it differs from the surrounding content's: the nearest
27
+ * ancestor's `dir` or language, else the document element's `xml:lang`, else left-to-right.
28
+ * An authored `dir` stays as authored.
29
+ *
30
+ * Docking puts the idref on the element's start tag, with two exceptions that wrap the element's
31
+ * content instead: a choice, whose attributes the transformers drop along with its tag, and an
32
+ * element that names a catalog already. An idref that cannot dock is left out, and the
33
+ * accessibility audit reports what it would have carried.
34
+ */
35
+ import type { TextRange } from './catalog.js';
36
+ export declare const HIDING_STYLES: {
37
+ readonly 'qti-hidden': "display:none";
38
+ readonly 'qti-visually-hidden': "position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0";
39
+ };
40
+ export declare const SSML_NAMESPACES: ReadonlySet<string>;
41
+ /** An idref to dock on the content element whose `id` is `target`, or on a range of its text. */
42
+ export interface ContentLink {
43
+ idref: string;
44
+ target: string;
45
+ range?: TextRange;
46
+ }
47
+ export interface PrepareContentMarkupOptions {
48
+ /** Restate the hiding classes as inline style. Default true. */
49
+ hidingStyles?: boolean;
50
+ }
51
+ export interface PreparedMarkup {
52
+ xml: string;
53
+ /** The `spoken` cards the content's SSML makes, by the idref each docked under. */
54
+ spoken: Array<{
55
+ identifier: string;
56
+ content: string;
57
+ }>;
58
+ }
59
+ /** Apply the accessibility edits to a QTI document's content. */
60
+ export declare function prepareContentMarkup(qtiXml: string, links?: ContentLink[], options?: PrepareContentMarkupOptions): PreparedMarkup;
61
+ export declare function escapeText(text: string): string;