@pie-qti/qti-common 0.1.27 → 1.0.0-beta.0
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.
- package/README.md +31 -86
- package/package.json +2 -3
- package/dist/accessibility/apip.d.ts +0 -66
- package/dist/accessibility/apip.js +0 -596
- package/dist/accessibility/apip.js.map +0 -1
- package/dist/accessibility/catalog.d.ts +0 -51
- package/dist/accessibility/catalog.js +0 -41
- package/dist/accessibility/catalog.js.map +0 -1
- package/dist/accessibility/index.d.ts +0 -2
- package/dist/accessibility/index.js +0 -3
- package/dist/accessibility/index.js.map +0 -1
- package/dist/dom/assignProps.d.ts +0 -4
- package/dist/dom/assignProps.js +0 -9
- package/dist/dom/assignProps.js.map +0 -1
- package/dist/dom/svelteMountController.d.ts +0 -25
- package/dist/dom/svelteMountController.js +0 -131
- package/dist/dom/svelteMountController.js.map +0 -1
- package/dist/dom/touchDrag.d.ts +0 -10
- package/dist/dom/touchDrag.js +0 -141
- package/dist/dom/touchDrag.js.map +0 -1
- package/dist/element-mapper/AttributeNameMapper.d.ts +0 -66
- package/dist/element-mapper/AttributeNameMapper.js +0 -2
- package/dist/element-mapper/AttributeNameMapper.js.map +0 -1
- package/dist/element-mapper/ElementNameMapper.d.ts +0 -66
- package/dist/element-mapper/ElementNameMapper.js +0 -2
- package/dist/element-mapper/ElementNameMapper.js.map +0 -1
- package/dist/element-mapper/Qti2xAttributeNameMapper.d.ts +0 -27
- package/dist/element-mapper/Qti2xAttributeNameMapper.js +0 -38
- package/dist/element-mapper/Qti2xAttributeNameMapper.js.map +0 -1
- package/dist/element-mapper/Qti2xElementNameMapper.d.ts +0 -37
- package/dist/element-mapper/Qti2xElementNameMapper.js +0 -47
- package/dist/element-mapper/Qti2xElementNameMapper.js.map +0 -1
- package/dist/element-mapper/Qti3AttributeNameMapper.d.ts +0 -40
- package/dist/element-mapper/Qti3AttributeNameMapper.js +0 -87
- package/dist/element-mapper/Qti3AttributeNameMapper.js.map +0 -1
- package/dist/element-mapper/Qti3ElementNameMapper.d.ts +0 -14
- package/dist/element-mapper/Qti3ElementNameMapper.js +0 -39
- package/dist/element-mapper/Qti3ElementNameMapper.js.map +0 -1
- package/dist/element-mapper/index.d.ts +0 -7
- package/dist/element-mapper/index.js +0 -6
- package/dist/element-mapper/index.js.map +0 -1
- package/dist/element-mapper/qti3-attribute-map.d.ts +0 -8
- package/dist/element-mapper/qti3-attribute-map.js +0 -115
- package/dist/element-mapper/qti3-attribute-map.js.map +0 -1
- package/dist/element-mapper/qti3-element-mappings.d.ts +0 -459
- package/dist/element-mapper/qti3-element-mappings.js +0 -328
- package/dist/element-mapper/qti3-element-mappings.js.map +0 -1
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -16
- package/dist/index.js.map +0 -1
- package/dist/parser-factory.d.ts +0 -137
- package/dist/parser-factory.js +0 -146
- package/dist/parser-factory.js.map +0 -1
- package/dist/version-detection/detectQtiVersion.d.ts +0 -23
- package/dist/version-detection/detectQtiVersion.js +0 -129
- package/dist/version-detection/detectQtiVersion.js.map +0 -1
- package/dist/version-detection/index.d.ts +0 -2
- package/dist/version-detection/index.js +0 -2
- package/dist/version-detection/index.js.map +0 -1
- package/dist/xml/attributes.d.ts +0 -77
- package/dist/xml/attributes.js +0 -120
- package/dist/xml/attributes.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
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,EAIZ,SAAS,GAET,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,cAAc,GAAG,4DAA4D,CAAC;AAC3F,MAAM,CAAC,MAAM,cAAc,GAAG,qCAAqC,CAAC;AAkCpE,MAAM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AAK,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,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\ttype MediaSource,\n\tmediaKind,\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 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};\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: mimeTypeOf(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\nfunction mimeTypeOf(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/** 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, '&').replace(/</g, '<').replace(/>/g, '>');\n}\n\nfunction escapeAttribute(value: string): string {\n\treturn escapeText(value).replace(/\"/g, '"');\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"]}
|
|
@@ -1,51 +0,0 @@
|
|
|
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 asset's kind, from its MIME type, else its extension, else `fallback`. */
|
|
49
|
-
export declare function mediaKind(type: string | undefined, src: string, fallback: MediaKind): MediaKind;
|
|
50
|
-
/** A clock value (`90`, `1:30`, `00:01:30.5`) as seconds; `undefined` when it is not one. */
|
|
51
|
-
export declare function clockSeconds(value: string): number | undefined;
|
|
@@ -1,41 +0,0 @@
|
|
|
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
|
-
/** A media asset's kind, from its MIME type, else its extension, else `fallback`. */
|
|
27
|
-
export function mediaKind(type, src, fallback) {
|
|
28
|
-
const prefix = type?.split('/')[0]?.toLowerCase();
|
|
29
|
-
if (prefix === 'image' || prefix === 'audio' || prefix === 'video')
|
|
30
|
-
return prefix;
|
|
31
|
-
const extension = /\.([a-z0-9]+)$/i.exec(src)?.[1]?.toLowerCase();
|
|
32
|
-
return (extension ? EXTENSION_KINDS[extension] : undefined) ?? fallback;
|
|
33
|
-
}
|
|
34
|
-
/** A clock value (`90`, `1:30`, `00:01:30.5`) as seconds; `undefined` when it is not one. */
|
|
35
|
-
export function clockSeconds(value) {
|
|
36
|
-
const parts = value.split(':').map(Number);
|
|
37
|
-
if (parts.length > 3 || parts.some((part) => !Number.isFinite(part)))
|
|
38
|
-
return undefined;
|
|
39
|
-
return parts.reduce((total, part) => total * 60 + part, 0);
|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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\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"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
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, type TextRange, } from './catalog.js';
|
|
@@ -1 +0,0 @@
|
|
|
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,GAET,MAAM,cAAc,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\ttype TextRange,\n} from './catalog.js';\n"]}
|
package/dist/dom/assignProps.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export function assignProps(node, props, options = {}) {
|
|
2
|
-
const { skipUndefined = true } = options;
|
|
3
|
-
for (const [key, value] of Object.entries(props)) {
|
|
4
|
-
if (skipUndefined && value === undefined)
|
|
5
|
-
continue;
|
|
6
|
-
node[key] = value;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=assignProps.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assignProps.js","sourceRoot":"","sources":["../../src/dom/assignProps.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,WAAW,CAAC,IAAiB,EAAE,KAA8B,EAAE,UAA8B,EAAE;IAC9G,MAAM,EAAE,aAAa,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACzC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,IAAI,aAAa,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClD,IAA2C,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC3D,CAAC;AACF,CAAC","sourcesContent":["export type AssignPropsOptions = {\n\tskipUndefined?: boolean;\n};\n\nexport function assignProps(node: HTMLElement, props: Record<string, unknown>, options: AssignPropsOptions = {}) {\n\tconst { skipUndefined = true } = options;\n\tfor (const [key, value] of Object.entries(props)) {\n\t\tif (skipUndefined && value === undefined) continue;\n\t\t(node as unknown as Record<string, unknown>)[key] = value;\n\t}\n}\n"]}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export interface SvelteMountControllerOptions<TProps, TInstance> {
|
|
2
|
-
host: HTMLElement;
|
|
3
|
-
mount: (target: HTMLElement, props: TProps) => TInstance;
|
|
4
|
-
/** Svelte 5's createSubscriber, supplied by the browser adapter's runtime. */
|
|
5
|
-
createSubscriber?: (start: (update: () => void) => () => void) => () => void;
|
|
6
|
-
unmount: (instance: TInstance) => void | Promise<void>;
|
|
7
|
-
createContainer?: () => HTMLElement;
|
|
8
|
-
}
|
|
9
|
-
export interface SvelteMountController<TProps, TInstance> {
|
|
10
|
-
readonly instance: TInstance | null;
|
|
11
|
-
readonly mounted: boolean;
|
|
12
|
-
mountOrUpdate(props: TProps): TInstance | null;
|
|
13
|
-
update(props: TProps): void;
|
|
14
|
-
teardown(options?: {
|
|
15
|
-
removeContainer?: boolean;
|
|
16
|
-
}): void;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Owns Svelte custom-element mount policy in one place.
|
|
20
|
-
*
|
|
21
|
-
* Svelte 5 adapters supply createSubscriber to track shallow reactive props so a
|
|
22
|
-
* response update preserves the component, input focus, and local state.
|
|
23
|
-
* The $set/remount fallback remains for existing callers without that bridge.
|
|
24
|
-
*/
|
|
25
|
-
export declare function createSvelteMountController<TProps, TInstance>({ host, mount, createSubscriber, unmount, createContainer, }: SvelteMountControllerOptions<TProps, TInstance>): SvelteMountController<TProps, TInstance>;
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Owns Svelte custom-element mount policy in one place.
|
|
3
|
-
*
|
|
4
|
-
* Svelte 5 adapters supply createSubscriber to track shallow reactive props so a
|
|
5
|
-
* response update preserves the component, input focus, and local state.
|
|
6
|
-
* The $set/remount fallback remains for existing callers without that bridge.
|
|
7
|
-
*/
|
|
8
|
-
export function createSvelteMountController({ host, mount, createSubscriber, unmount, createContainer = defaultContainer, }) {
|
|
9
|
-
let container = null;
|
|
10
|
-
let instance = null;
|
|
11
|
-
let pendingRemount = false;
|
|
12
|
-
let latestProps = null;
|
|
13
|
-
let notifyProps;
|
|
14
|
-
const trackProps = createSubscriber?.((update) => {
|
|
15
|
-
notifyProps = update;
|
|
16
|
-
return () => { notifyProps = undefined; };
|
|
17
|
-
});
|
|
18
|
-
// Track reads without deep-proxying externally owned sessions and providers.
|
|
19
|
-
const reactiveProps = trackProps ? new Proxy({}, {
|
|
20
|
-
get(_target, key) {
|
|
21
|
-
trackProps();
|
|
22
|
-
return Reflect.get(latestProps, key);
|
|
23
|
-
},
|
|
24
|
-
has(_target, key) {
|
|
25
|
-
trackProps();
|
|
26
|
-
return Reflect.has(latestProps, key);
|
|
27
|
-
},
|
|
28
|
-
ownKeys() {
|
|
29
|
-
trackProps();
|
|
30
|
-
return Reflect.ownKeys(latestProps);
|
|
31
|
-
},
|
|
32
|
-
getOwnPropertyDescriptor(_target, key) {
|
|
33
|
-
trackProps();
|
|
34
|
-
return Reflect.has(latestProps, key)
|
|
35
|
-
? { configurable: true, enumerable: true }
|
|
36
|
-
: undefined;
|
|
37
|
-
},
|
|
38
|
-
}) : undefined;
|
|
39
|
-
function ensureContainer() {
|
|
40
|
-
if (!container) {
|
|
41
|
-
container = createContainer();
|
|
42
|
-
host.appendChild(container);
|
|
43
|
-
}
|
|
44
|
-
return container;
|
|
45
|
-
}
|
|
46
|
-
function mountFresh(props) {
|
|
47
|
-
latestProps = props;
|
|
48
|
-
instance = mount(ensureContainer(), reactiveProps ?? props);
|
|
49
|
-
return instance;
|
|
50
|
-
}
|
|
51
|
-
function scheduleRemount() {
|
|
52
|
-
if (pendingRemount)
|
|
53
|
-
return;
|
|
54
|
-
pendingRemount = true;
|
|
55
|
-
queueMicrotask(() => {
|
|
56
|
-
pendingRemount = false;
|
|
57
|
-
if (!host.isConnected || !container || latestProps === null)
|
|
58
|
-
return;
|
|
59
|
-
teardownInstance();
|
|
60
|
-
mountFresh(latestProps);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
function teardownInstance() {
|
|
64
|
-
if (!instance)
|
|
65
|
-
return;
|
|
66
|
-
try {
|
|
67
|
-
void unmount(instance);
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
// Unmount should not make custom-element disconnection throw.
|
|
71
|
-
}
|
|
72
|
-
instance = null;
|
|
73
|
-
}
|
|
74
|
-
function mountOrUpdate(props) {
|
|
75
|
-
latestProps = props;
|
|
76
|
-
if (!instance) {
|
|
77
|
-
return mountFresh(props);
|
|
78
|
-
}
|
|
79
|
-
update(props);
|
|
80
|
-
return instance;
|
|
81
|
-
}
|
|
82
|
-
function update(props) {
|
|
83
|
-
latestProps = props;
|
|
84
|
-
if (!instance)
|
|
85
|
-
return;
|
|
86
|
-
if (trackProps) {
|
|
87
|
-
notifyProps?.();
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
const set = instance.$set;
|
|
91
|
-
if (typeof set === 'function') {
|
|
92
|
-
try {
|
|
93
|
-
set.call(instance, props);
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
if (!isSvelteComponentApiChanged(error))
|
|
98
|
-
throw error;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
scheduleRemount();
|
|
102
|
-
}
|
|
103
|
-
function teardown(options = {}) {
|
|
104
|
-
pendingRemount = false;
|
|
105
|
-
teardownInstance();
|
|
106
|
-
if (options.removeContainer ?? true) {
|
|
107
|
-
container?.remove();
|
|
108
|
-
container = null;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return {
|
|
112
|
-
get instance() {
|
|
113
|
-
return instance;
|
|
114
|
-
},
|
|
115
|
-
get mounted() {
|
|
116
|
-
return instance !== null;
|
|
117
|
-
},
|
|
118
|
-
mountOrUpdate,
|
|
119
|
-
update,
|
|
120
|
-
teardown,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function isSvelteComponentApiChanged(error) {
|
|
124
|
-
return error instanceof Error && error.message.includes('https://svelte.dev/e/component_api_changed');
|
|
125
|
-
}
|
|
126
|
-
function defaultContainer() {
|
|
127
|
-
const container = document.createElement('div');
|
|
128
|
-
container.style.display = 'contents';
|
|
129
|
-
return container;
|
|
130
|
-
}
|
|
131
|
-
//# sourceMappingURL=svelteMountController.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"svelteMountController.js","sourceRoot":"","sources":["../../src/dom/svelteMountController.ts"],"names":[],"mappings":"AAqBA;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CAAoB,EAC9D,IAAI,EACJ,KAAK,EACL,gBAAgB,EAChB,OAAO,EACP,eAAe,GAAG,gBAAgB,GACe;IACjD,IAAI,SAAS,GAAuB,IAAI,CAAC;IACzC,IAAI,QAAQ,GAAqB,IAAI,CAAC;IACtC,IAAI,cAAc,GAAG,KAAK,CAAC;IAC3B,IAAI,WAAW,GAAkB,IAAI,CAAC;IACtC,IAAI,WAAqC,CAAC;IAC1C,MAAM,UAAU,GAAG,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE;QAChD,WAAW,GAAG,MAAM,CAAC;QACrB,OAAO,GAAG,EAAE,GAAG,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IACH,6EAA6E;IAC7E,MAAM,aAAa,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,EAAE,EAAE;QAChD,GAAG,CAAC,OAAO,EAAE,GAAG;YACf,UAAU,EAAE,CAAC;YACb,OAAO,OAAO,CAAC,GAAG,CAAC,WAAqB,EAAE,GAAG,CAAC,CAAC;QAChD,CAAC;QACD,GAAG,C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,CAAC;QACjB,CAAC;QACD,IAAI,OAAO;YACV,OAAO,QAAQ,KAAK,IAAI,CAAC;QAC1B,CAAC;QACD,aAAa;QACb,MAAM;QACN,QAAQ;KACR,CAAC;AACH,CAAC;AAED,SAAS,2BAA2B,CAAC,KAAc;IAClD,OAAO,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,4CAA4C,CAAC,CAAC;AACvG,CAAC;AAED,SAAS,gBAAgB;IACxB,MAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAChD,SAAS,CAAC,KAAK,CAAC,OAAO,GAAG,UAAU,CAAC;IACrC,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["export interface SvelteMountControllerOptions<TProps, TInstance> {\n\thost: HTMLElement;\n\tmount: (target: HTMLElement, props: TProps) => TInstance;\n\t/** Svelte 5's createSubscriber, supplied by the browser adapter's runtime. */\n\tcreateSubscriber?: (start: (update: () => void) => () => void) => () => void;\n\tunmount: (instance: TInstance) => void | Promise<void>;\n\tcreateContainer?: () => HTMLElement;\n}\n\nexport interface SvelteMountController<TProps, TInstance> {\n\treadonly instance: TInstance | null;\n\treadonly mounted: boolean;\n\tmountOrUpdate(props: TProps): TInstance | null;\n\tupdate(props: TProps): void;\n\tteardown(options?: { removeContainer?: boolean }): void;\n}\n\ntype SettableSvelteInstance<TProps> = {\n\t$set?: (props: TProps) => void;\n};\n\n/**\n * Owns Svelte custom-element mount policy in one place.\n *\n * Svelte 5 adapters supply createSubscriber to track shallow reactive props so a\n * response update preserves the component, input focus, and local state.\n * The $set/remount fallback remains for existing callers without that bridge.\n */\nexport function createSvelteMountController<TProps, TInstance>({\n\thost,\n\tmount,\n\tcreateSubscriber,\n\tunmount,\n\tcreateContainer = defaultContainer,\n}: SvelteMountControllerOptions<TProps, TInstance>): SvelteMountController<TProps, TInstance> {\n\tlet container: HTMLElement | null = null;\n\tlet instance: TInstance | null = null;\n\tlet pendingRemount = false;\n\tlet latestProps: TProps | null = null;\n\tlet notifyProps: (() => void) | undefined;\n\tconst trackProps = createSubscriber?.((update) => {\n\t\tnotifyProps = update;\n\t\treturn () => { notifyProps = undefined; };\n\t});\n\t// Track reads without deep-proxying externally owned sessions and providers.\n\tconst reactiveProps = trackProps ? new Proxy({}, {\n\t\tget(_target, key) {\n\t\t\ttrackProps();\n\t\t\treturn Reflect.get(latestProps as object, key);\n\t\t},\n\t\thas(_target, key) {\n\t\t\ttrackProps();\n\t\t\treturn Reflect.has(latestProps as object, key);\n\t\t},\n\t\townKeys() {\n\t\t\ttrackProps();\n\t\t\treturn Reflect.ownKeys(latestProps as object);\n\t\t},\n\t\tgetOwnPropertyDescriptor(_target, key) {\n\t\t\ttrackProps();\n\t\t\treturn Reflect.has(latestProps as object, key)\n\t\t\t\t? { configurable: true, enumerable: true }\n\t\t\t\t: undefined;\n\t\t},\n\t}) as TProps : undefined;\n\n\tfunction ensureContainer() {\n\t\tif (!container) {\n\t\t\tcontainer = createContainer();\n\t\t\thost.appendChild(container);\n\t\t}\n\t\treturn container;\n\t}\n\n\tfunction mountFresh(props: TProps) {\n\t\tlatestProps = props;\n\t\tinstance = mount(ensureContainer(), reactiveProps ?? props);\n\t\treturn instance;\n\t}\n\n\tfunction scheduleRemount() {\n\t\tif (pendingRemount) return;\n\t\tpendingRemount = true;\n\t\tqueueMicrotask(() => {\n\t\t\tpendingRemount = false;\n\t\t\tif (!host.isConnected || !container || latestProps === null) return;\n\t\t\tteardownInstance();\n\t\t\tmountFresh(latestProps);\n\t\t});\n\t}\n\n\tfunction teardownInstance() {\n\t\tif (!instance) return;\n\t\ttry {\n\t\t\tvoid unmount(instance);\n\t\t} catch {\n\t\t\t// Unmount should not make custom-element disconnection throw.\n\t\t}\n\t\tinstance = null;\n\t}\n\n\tfunction mountOrUpdate(props: TProps) {\n\t\tlatestProps = props;\n\t\tif (!instance) {\n\t\t\treturn mountFresh(props);\n\t\t}\n\t\tupdate(props);\n\t\treturn instance;\n\t}\n\n\tfunction update(props: TProps) {\n\t\tlatestProps = props;\n\t\tif (!instance) return;\n\t\tif (trackProps) {\n\t\t\tnotifyProps?.();\n\t\t\treturn;\n\t\t}\n\n\t\tconst set = (instance as SettableSvelteInstance<TProps>).$set;\n\t\tif (typeof set === 'function') {\n\t\t\ttry {\n\t\t\t\tset.call(instance, props);\n\t\t\t\treturn;\n\t\t\t} catch (error) {\n\t\t\t\tif (!isSvelteComponentApiChanged(error)) throw error;\n\t\t\t}\n\t\t}\n\n\t\tscheduleRemount();\n\t}\n\n\tfunction teardown(options: { removeContainer?: boolean } = {}) {\n\t\tpendingRemount = false;\n\t\tteardownInstance();\n\t\tif (options.removeContainer ?? true) {\n\t\t\tcontainer?.remove();\n\t\t\tcontainer = null;\n\t\t}\n\t}\n\n\treturn {\n\t\tget instance() {\n\t\t\treturn instance;\n\t\t},\n\t\tget mounted() {\n\t\t\treturn instance !== null;\n\t\t},\n\t\tmountOrUpdate,\n\t\tupdate,\n\t\tteardown,\n\t};\n}\n\nfunction isSvelteComponentApiChanged(error: unknown): error is Error {\n\treturn error instanceof Error && error.message.includes('https://svelte.dev/e/component_api_changed');\n}\n\nfunction defaultContainer() {\n\tconst container = document.createElement('div');\n\tcontainer.style.display = 'contents';\n\treturn container;\n}\n"]}
|
package/dist/dom/touchDrag.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare function touchDrag(node: HTMLElement): {
|
|
2
|
-
destroy(): void;
|
|
3
|
-
};
|
|
4
|
-
export declare const touchDragStyles: {
|
|
5
|
-
readonly userSelect: "none";
|
|
6
|
-
readonly webkitUserSelect: "none";
|
|
7
|
-
readonly touchAction: "none";
|
|
8
|
-
readonly cursor: "grab";
|
|
9
|
-
readonly transition: "opacity 0.2s ease";
|
|
10
|
-
};
|
package/dist/dom/touchDrag.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
function deepestElementFromPoint(owner, x, y) {
|
|
2
|
-
let element = owner.elementFromPoint(x, y);
|
|
3
|
-
while (element?.shadowRoot) {
|
|
4
|
-
const inner = element.shadowRoot.elementFromPoint(x, y);
|
|
5
|
-
if (!inner || inner === element)
|
|
6
|
-
break;
|
|
7
|
-
element = inner;
|
|
8
|
-
}
|
|
9
|
-
return element;
|
|
10
|
-
}
|
|
11
|
-
export function touchDrag(node) {
|
|
12
|
-
const ownerDocument = node.ownerDocument;
|
|
13
|
-
const state = {
|
|
14
|
-
element: node,
|
|
15
|
-
touchId: null,
|
|
16
|
-
isDragging: false,
|
|
17
|
-
startX: 0,
|
|
18
|
-
startY: 0,
|
|
19
|
-
currentX: 0,
|
|
20
|
-
currentY: 0,
|
|
21
|
-
dragThreshold: 10,
|
|
22
|
-
};
|
|
23
|
-
function handleTouchStart(e) {
|
|
24
|
-
if (e.touches.length !== 1)
|
|
25
|
-
return;
|
|
26
|
-
const draggable = node.getAttribute('draggable');
|
|
27
|
-
if (draggable !== 'true')
|
|
28
|
-
return;
|
|
29
|
-
const touch = e.touches[0];
|
|
30
|
-
state.touchId = touch.identifier;
|
|
31
|
-
state.startX = touch.clientX;
|
|
32
|
-
state.startY = touch.clientY;
|
|
33
|
-
state.currentX = touch.clientX;
|
|
34
|
-
state.currentY = touch.clientY;
|
|
35
|
-
state.isDragging = false;
|
|
36
|
-
ownerDocument.addEventListener('touchmove', handleTouchMove, { passive: false });
|
|
37
|
-
ownerDocument.addEventListener('touchend', handleTouchEnd);
|
|
38
|
-
ownerDocument.addEventListener('touchcancel', handleTouchCancel);
|
|
39
|
-
}
|
|
40
|
-
function handleTouchMove(e) {
|
|
41
|
-
if (state.touchId === null)
|
|
42
|
-
return;
|
|
43
|
-
const touch = Array.from(e.changedTouches).find(t => t.identifier === state.touchId);
|
|
44
|
-
if (!touch)
|
|
45
|
-
return;
|
|
46
|
-
state.currentX = touch.clientX;
|
|
47
|
-
state.currentY = touch.clientY;
|
|
48
|
-
const deltaX = state.currentX - state.startX;
|
|
49
|
-
const deltaY = state.currentY - state.startY;
|
|
50
|
-
const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
51
|
-
if (!state.isDragging && distance > state.dragThreshold) {
|
|
52
|
-
state.isDragging = true;
|
|
53
|
-
const dragStartEvent = new DragEvent('dragstart', {
|
|
54
|
-
bubbles: true,
|
|
55
|
-
composed: true,
|
|
56
|
-
cancelable: true,
|
|
57
|
-
clientX: state.startX,
|
|
58
|
-
clientY: state.startY,
|
|
59
|
-
});
|
|
60
|
-
node.dispatchEvent(dragStartEvent);
|
|
61
|
-
node.style.opacity = '0.5';
|
|
62
|
-
e.preventDefault();
|
|
63
|
-
}
|
|
64
|
-
if (state.isDragging) {
|
|
65
|
-
e.preventDefault();
|
|
66
|
-
const elementUnder = deepestElementFromPoint(ownerDocument, state.currentX, state.currentY);
|
|
67
|
-
if (elementUnder && elementUnder !== node) {
|
|
68
|
-
const dragOverEvent = new DragEvent('dragover', {
|
|
69
|
-
bubbles: true,
|
|
70
|
-
composed: true,
|
|
71
|
-
cancelable: true,
|
|
72
|
-
clientX: state.currentX,
|
|
73
|
-
clientY: state.currentY,
|
|
74
|
-
});
|
|
75
|
-
elementUnder.dispatchEvent(dragOverEvent);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function handleTouchEnd(e) {
|
|
80
|
-
if (state.touchId === null)
|
|
81
|
-
return;
|
|
82
|
-
const touch = Array.from(e.changedTouches).find(t => t.identifier === state.touchId);
|
|
83
|
-
if (!touch)
|
|
84
|
-
return;
|
|
85
|
-
if (state.isDragging) {
|
|
86
|
-
const elementUnder = deepestElementFromPoint(ownerDocument, touch.clientX, touch.clientY);
|
|
87
|
-
if (elementUnder) {
|
|
88
|
-
const dropEvent = new DragEvent('drop', {
|
|
89
|
-
bubbles: true,
|
|
90
|
-
composed: true,
|
|
91
|
-
cancelable: true,
|
|
92
|
-
clientX: touch.clientX,
|
|
93
|
-
clientY: touch.clientY,
|
|
94
|
-
});
|
|
95
|
-
elementUnder.dispatchEvent(dropEvent);
|
|
96
|
-
}
|
|
97
|
-
const dragEndEvent = new DragEvent('dragend', {
|
|
98
|
-
bubbles: true,
|
|
99
|
-
composed: true,
|
|
100
|
-
cancelable: true,
|
|
101
|
-
});
|
|
102
|
-
node.dispatchEvent(dragEndEvent);
|
|
103
|
-
node.style.opacity = '';
|
|
104
|
-
}
|
|
105
|
-
cleanup();
|
|
106
|
-
}
|
|
107
|
-
function handleTouchCancel() {
|
|
108
|
-
if (state.isDragging) {
|
|
109
|
-
const dragEndEvent = new DragEvent('dragend', {
|
|
110
|
-
bubbles: true,
|
|
111
|
-
composed: true,
|
|
112
|
-
cancelable: true,
|
|
113
|
-
});
|
|
114
|
-
node.dispatchEvent(dragEndEvent);
|
|
115
|
-
node.style.opacity = '';
|
|
116
|
-
}
|
|
117
|
-
cleanup();
|
|
118
|
-
}
|
|
119
|
-
function cleanup() {
|
|
120
|
-
state.touchId = null;
|
|
121
|
-
state.isDragging = false;
|
|
122
|
-
ownerDocument.removeEventListener('touchmove', handleTouchMove);
|
|
123
|
-
ownerDocument.removeEventListener('touchend', handleTouchEnd);
|
|
124
|
-
ownerDocument.removeEventListener('touchcancel', handleTouchCancel);
|
|
125
|
-
}
|
|
126
|
-
node.addEventListener('touchstart', handleTouchStart, { passive: true });
|
|
127
|
-
return {
|
|
128
|
-
destroy() {
|
|
129
|
-
node.removeEventListener('touchstart', handleTouchStart);
|
|
130
|
-
handleTouchCancel();
|
|
131
|
-
},
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
export const touchDragStyles = {
|
|
135
|
-
userSelect: 'none',
|
|
136
|
-
webkitUserSelect: 'none',
|
|
137
|
-
touchAction: 'none',
|
|
138
|
-
cursor: 'grab',
|
|
139
|
-
transition: 'opacity 0.2s ease',
|
|
140
|
-
};
|
|
141
|
-
//# sourceMappingURL=touchDrag.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"touchDrag.js","sourceRoot":"","sources":["../../src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AC;QAC9D,aAAa,CAAC,mBAAmB,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,gBAAgB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAEzE,OAAO;QACN,OAAO;YACN,IAAI,CAAC,mBAAmB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;YACzD,iBAAiB,EAAE,CAAC;QACrB,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B,UAAU,EAAE,MAAM;IAClB,gBAAgB,EAAE,MAAM;IACxB,WAAW,EAAE,MAAM;IACnB,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,mBAAmB;CACtB,CAAC","sourcesContent":["interface TouchDragState {\n\telement: HTMLElement;\n\ttouchId: number | null;\n\tisDragging: boolean;\n\tstartX: number;\n\tstartY: number;\n\tcurrentX: number;\n\tcurrentY: number;\n\tdragThreshold: number;\n}\n\nfunction deepestElementFromPoint(owner: Document, x: number, y: number): Element | null {\n\tlet element = owner.elementFromPoint(x, y);\n\twhile (element?.shadowRoot) {\n\t\tconst inner = element.shadowRoot.elementFromPoint(x, y);\n\t\tif (!inner || inner === element) break;\n\t\telement = inner;\n\t}\n\treturn element;\n}\n\nexport function touchDrag(node: HTMLElement) {\n\tconst ownerDocument = node.ownerDocument;\n\tconst state: TouchDragState = {\n\t\telement: node,\n\t\ttouchId: null,\n\t\tisDragging: false,\n\t\tstartX: 0,\n\t\tstartY: 0,\n\t\tcurrentX: 0,\n\t\tcurrentY: 0,\n\t\tdragThreshold: 10,\n\t};\n\n\tfunction handleTouchStart(e: TouchEvent) {\n\t\tif (e.touches.length !== 1) return;\n\n\t\tconst draggable = node.getAttribute('draggable');\n\t\tif (draggable !== 'true') return;\n\n\t\tconst touch = e.touches[0];\n\t\tstate.touchId = touch.identifier;\n\t\tstate.startX = touch.clientX;\n\t\tstate.startY = touch.clientY;\n\t\tstate.currentX = touch.clientX;\n\t\tstate.currentY = touch.clientY;\n\t\tstate.isDragging = false;\n\n\t\townerDocument.addEventListener('touchmove', handleTouchMove, { passive: false });\n\t\townerDocument.addEventListener('touchend', handleTouchEnd);\n\t\townerDocument.addEventListener('touchcancel', handleTouchCancel);\n\t}\n\n\tfunction handleTouchMove(e: TouchEvent) {\n\t\tif (state.touchId === null) return;\n\n\t\tconst touch = Array.from(e.changedTouches).find(t => t.identifier === state.touchId);\n\t\tif (!touch) return;\n\n\t\tstate.currentX = touch.clientX;\n\t\tstate.currentY = touch.clientY;\n\n\t\tconst deltaX = state.currentX - state.startX;\n\t\tconst deltaY = state.currentY - state.startY;\n\t\tconst distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);\n\n\t\tif (!state.isDragging && distance > state.dragThreshold) {\n\t\t\tstate.isDragging = true;\n\n\t\t\tconst dragStartEvent = new DragEvent('dragstart', {\n\t\t\t\tbubbles: true,\n\t\t\t\tcomposed: true,\n\t\t\t\tcancelable: true,\n\t\t\t\tclientX: state.startX,\n\t\t\t\tclientY: state.startY,\n\t\t\t});\n\n\t\t\tnode.dispatchEvent(dragStartEvent);\n\t\t\tnode.style.opacity = '0.5';\n\t\t\te.preventDefault();\n\t\t}\n\n\t\tif (state.isDragging) {\n\t\t\te.preventDefault();\n\n\t\t\tconst elementUnder = deepestElementFromPoint(ownerDocument, state.currentX, state.currentY);\n\t\t\tif (elementUnder && elementUnder !== node) {\n\t\t\t\tconst dragOverEvent = new DragEvent('dragover', {\n\t\t\t\t\tbubbles: true,\n\t\t\t\t\tcomposed: true,\n\t\t\t\t\tcancelable: true,\n\t\t\t\t\tclientX: state.currentX,\n\t\t\t\t\tclientY: state.currentY,\n\t\t\t\t});\n\n\t\t\t\telementUnder.dispatchEvent(dragOverEvent);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction handleTouchEnd(e: TouchEvent) {\n\t\tif (state.touchId === null) return;\n\n\t\tconst touch = Array.from(e.changedTouches).find(t => t.identifier === state.touchId);\n\t\tif (!touch) return;\n\n\t\tif (state.isDragging) {\n\t\t\tconst elementUnder = deepestElementFromPoint(ownerDocument, touch.clientX, touch.clientY);\n\t\t\tif (elementUnder) {\n\t\t\t\tconst dropEvent = new DragEvent('drop', {\n\t\t\t\t\tbubbles: true,\n\t\t\t\t\tcomposed: true,\n\t\t\t\t\tcancelable: true,\n\t\t\t\t\tclientX: touch.clientX,\n\t\t\t\t\tclientY: touch.clientY,\n\t\t\t\t});\n\n\t\t\t\telementUnder.dispatchEvent(dropEvent);\n\t\t\t}\n\n\t\t\tconst dragEndEvent = new DragEvent('dragend', {\n\t\t\t\tbubbles: true,\n\t\t\t\tcomposed: true,\n\t\t\t\tcancelable: true,\n\t\t\t});\n\n\t\t\tnode.dispatchEvent(dragEndEvent);\n\t\t\tnode.style.opacity = '';\n\t\t}\n\n\t\tcleanup();\n\t}\n\n\tfunction handleTouchCancel() {\n\t\tif (state.isDragging) {\n\t\t\tconst dragEndEvent = new DragEvent('dragend', {\n\t\t\t\tbubbles: true,\n\t\t\t\tcomposed: true,\n\t\t\t\tcancelable: true,\n\t\t\t});\n\t\t\tnode.dispatchEvent(dragEndEvent);\n\t\t\tnode.style.opacity = '';\n\t\t}\n\n\t\tcleanup();\n\t}\n\n\tfunction cleanup() {\n\t\tstate.touchId = null;\n\t\tstate.isDragging = false;\n\n\t\townerDocument.removeEventListener('touchmove', handleTouchMove);\n\t\townerDocument.removeEventListener('touchend', handleTouchEnd);\n\t\townerDocument.removeEventListener('touchcancel', handleTouchCancel);\n\t}\n\n\tnode.addEventListener('touchstart', handleTouchStart, { passive: true });\n\n\treturn {\n\t\tdestroy() {\n\t\t\tnode.removeEventListener('touchstart', handleTouchStart);\n\t\t\thandleTouchCancel();\n\t\t},\n\t};\n}\n\nexport const touchDragStyles = {\n\tuserSelect: 'none',\n\twebkitUserSelect: 'none',\n\ttouchAction: 'none',\n\tcursor: 'grab',\n\ttransition: 'opacity 0.2s ease',\n} as const;\n"]}
|