@pie-qti/qti-common 0.1.28 → 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.
Files changed (68) hide show
  1. package/README.md +31 -86
  2. package/package.json +2 -3
  3. package/dist/accessibility/apip.d.ts +0 -66
  4. package/dist/accessibility/apip.js +0 -576
  5. package/dist/accessibility/apip.js.map +0 -1
  6. package/dist/accessibility/catalog-info.d.ts +0 -17
  7. package/dist/accessibility/catalog-info.js +0 -60
  8. package/dist/accessibility/catalog-info.js.map +0 -1
  9. package/dist/accessibility/catalog.d.ts +0 -53
  10. package/dist/accessibility/catalog.js +0 -68
  11. package/dist/accessibility/catalog.js.map +0 -1
  12. package/dist/accessibility/index.d.ts +0 -3
  13. package/dist/accessibility/index.js +0 -4
  14. package/dist/accessibility/index.js.map +0 -1
  15. package/dist/dom/assignProps.d.ts +0 -4
  16. package/dist/dom/assignProps.js +0 -9
  17. package/dist/dom/assignProps.js.map +0 -1
  18. package/dist/dom/svelteMountController.d.ts +0 -25
  19. package/dist/dom/svelteMountController.js +0 -131
  20. package/dist/dom/svelteMountController.js.map +0 -1
  21. package/dist/dom/touchDrag.d.ts +0 -10
  22. package/dist/dom/touchDrag.js +0 -141
  23. package/dist/dom/touchDrag.js.map +0 -1
  24. package/dist/element-mapper/AttributeNameMapper.d.ts +0 -66
  25. package/dist/element-mapper/AttributeNameMapper.js +0 -2
  26. package/dist/element-mapper/AttributeNameMapper.js.map +0 -1
  27. package/dist/element-mapper/ElementNameMapper.d.ts +0 -66
  28. package/dist/element-mapper/ElementNameMapper.js +0 -2
  29. package/dist/element-mapper/ElementNameMapper.js.map +0 -1
  30. package/dist/element-mapper/Qti2xAttributeNameMapper.d.ts +0 -27
  31. package/dist/element-mapper/Qti2xAttributeNameMapper.js +0 -38
  32. package/dist/element-mapper/Qti2xAttributeNameMapper.js.map +0 -1
  33. package/dist/element-mapper/Qti2xElementNameMapper.d.ts +0 -37
  34. package/dist/element-mapper/Qti2xElementNameMapper.js +0 -47
  35. package/dist/element-mapper/Qti2xElementNameMapper.js.map +0 -1
  36. package/dist/element-mapper/Qti3AttributeNameMapper.d.ts +0 -40
  37. package/dist/element-mapper/Qti3AttributeNameMapper.js +0 -87
  38. package/dist/element-mapper/Qti3AttributeNameMapper.js.map +0 -1
  39. package/dist/element-mapper/Qti3ElementNameMapper.d.ts +0 -14
  40. package/dist/element-mapper/Qti3ElementNameMapper.js +0 -39
  41. package/dist/element-mapper/Qti3ElementNameMapper.js.map +0 -1
  42. package/dist/element-mapper/index.d.ts +0 -8
  43. package/dist/element-mapper/index.js +0 -7
  44. package/dist/element-mapper/index.js.map +0 -1
  45. package/dist/element-mapper/qti2-to-qti3.d.ts +0 -36
  46. package/dist/element-mapper/qti2-to-qti3.js +0 -228
  47. package/dist/element-mapper/qti2-to-qti3.js.map +0 -1
  48. package/dist/element-mapper/qti3-attribute-map.d.ts +0 -8
  49. package/dist/element-mapper/qti3-attribute-map.js +0 -115
  50. package/dist/element-mapper/qti3-attribute-map.js.map +0 -1
  51. package/dist/element-mapper/qti3-element-mappings.d.ts +0 -538
  52. package/dist/element-mapper/qti3-element-mappings.js +0 -381
  53. package/dist/element-mapper/qti3-element-mappings.js.map +0 -1
  54. package/dist/index.d.ts +0 -15
  55. package/dist/index.js +0 -17
  56. package/dist/index.js.map +0 -1
  57. package/dist/parser-factory.d.ts +0 -137
  58. package/dist/parser-factory.js +0 -146
  59. package/dist/parser-factory.js.map +0 -1
  60. package/dist/version-detection/detectQtiVersion.d.ts +0 -23
  61. package/dist/version-detection/detectQtiVersion.js +0 -129
  62. package/dist/version-detection/detectQtiVersion.js.map +0 -1
  63. package/dist/version-detection/index.d.ts +0 -2
  64. package/dist/version-detection/index.js +0 -2
  65. package/dist/version-detection/index.js.map +0 -1
  66. package/dist/xml/attributes.d.ts +0 -77
  67. package/dist/xml/attributes.js +0 -120
  68. package/dist/xml/attributes.js.map +0 -1
@@ -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
- //# sour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AAE,eAAe,CAAC,CAAC;QAChE,aAAa,CAAC,mBAAmB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;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"]}
@@ -1,66 +0,0 @@
1
- /**
2
- * Interface for mapping between QTI version-specific attribute names and canonical forms.
3
- *
4
- * QTI 2.x uses camelCase (e.g., 'responseIdentifier', 'maxChoices', 'baseType')
5
- * QTI 3.0 uses kebab-case (e.g., 'response-identifier', 'max-choices', 'base-type')
6
- *
7
- * This abstraction allows the parser and extractors to work with both versions
8
- * by converting to/from a canonical camelCase form for internal processing.
9
- */
10
- export interface AttributeNameMapper {
11
- /**
12
- * Convert QTI-version-specific attribute name to canonical camelCase form.
13
- *
14
- * @param attributeName - The attribute name as it appears in the XML
15
- * @returns Canonical camelCase name for internal processing
16
- *
17
- * @example
18
- * // QTI 2.x
19
- * toCanonical('responseIdentifier') // => 'responseIdentifier'
20
- * toCanonical('maxChoices') // => 'maxChoices'
21
- *
22
- * @example
23
- * // QTI 3.0
24
- * toCanonical('response-identifier') // => 'responseIdentifier'
25
- * toCanonical('max-choices') // => 'maxChoices'
26
- */
27
- toCanonical(attributeName: string): string;
28
- /**
29
- * Convert canonical name back to version-specific form.
30
- *
31
- * @param canonicalName - camelCase canonical name
32
- * @returns Version-specific attribute name
33
- *
34
- * @example
35
- * // QTI 2.x
36
- * toNative('responseIdentifier') // => 'responseIdentifier'
37
- * toNative('maxChoices') // => 'maxChoices'
38
- *
39
- * @example
40
- * // QTI 3.0
41
- * toNative('responseIdentifier') // => 'response-identifier'
42
- * toNative('maxChoices') // => 'max-choices'
43
- */
44
- toNative(canonicalName: string): string;
45
- /**
46
- * Check if attribute name matches expected pattern for this QTI version.
47
- *
48
- * @param attributeName - Attribute name to validate
49
- * @returns true if valid for this version
50
- *
51
- * @example
52
- * // QTI 2.x mapper
53
- * isValidAttributeName('responseIdentifier') // => true
54
- * isValidAttributeName('response-identifier') // => false
55
- *
56
- * @example
57
- * // QTI 3.0 mapper
58
- * isValidAttributeName('response-identifier') // => true
59
- * isValidAttributeName('responseIdentifier') // => false
60
- */
61
- isValidAttributeName(attributeName: string): boolean;
62
- /**
63
- * Get the QTI version this mapper handles.
64
- */
65
- readonly version: string;
66
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=AttributeNameMapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AttributeNameMapper.js","sourceRoot":"","sources":["../../src/element-mapper/AttributeNameMapper.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Interface for mapping between QTI version-specific attribute names and canonical forms.\n *\n * QTI 2.x uses camelCase (e.g., 'responseIdentifier', 'maxChoices', 'baseType')\n * QTI 3.0 uses kebab-case (e.g., 'response-identifier', 'max-choices', 'base-type')\n *\n * This abstraction allows the parser and extractors to work with both versions\n * by converting to/from a canonical camelCase form for internal processing.\n */\nexport interface AttributeNameMapper {\n\t/**\n\t * Convert QTI-version-specific attribute name to canonical camelCase form.\n\t *\n\t * @param attributeName - The attribute name as it appears in the XML\n\t * @returns Canonical camelCase name for internal processing\n\t *\n\t * @example\n\t * // QTI 2.x\n\t * toCanonical('responseIdentifier') // => 'responseIdentifier'\n\t * toCanonical('maxChoices') // => 'maxChoices'\n\t *\n\t * @example\n\t * // QTI 3.0\n\t * toCanonical('response-identifier') // => 'responseIdentifier'\n\t * toCanonical('max-choices') // => 'maxChoices'\n\t */\n\ttoCanonical(attributeName: string): string;\n\n\t/**\n\t * Convert canonical name back to version-specific form.\n\t *\n\t * @param canonicalName - camelCase canonical name\n\t * @returns Version-specific attribute name\n\t *\n\t * @example\n\t * // QTI 2.x\n\t * toNative('responseIdentifier') // => 'responseIdentifier'\n\t * toNative('maxChoices') // => 'maxChoices'\n\t *\n\t * @example\n\t * // QTI 3.0\n\t * toNative('responseIdentifier') // => 'response-identifier'\n\t * toNative('maxChoices') // => 'max-choices'\n\t */\n\ttoNative(canonicalName: string): string;\n\n\t/**\n\t * Check if attribute name matches expected pattern for this QTI version.\n\t *\n\t * @param attributeName - Attribute name to validate\n\t * @returns true if valid for this version\n\t *\n\t * @example\n\t * // QTI 2.x mapper\n\t * isValidAttributeName('responseIdentifier') // => true\n\t * isValidAttributeName('response-identifier') // => false\n\t *\n\t * @example\n\t * // QTI 3.0 mapper\n\t * isValidAttributeName('response-identifier') // => true\n\t * isValidAttributeName('responseIdentifier') // => false\n\t */\n\tisValidAttributeName(attributeName: string): boolean;\n\n\t/**\n\t * Get the QTI version this mapper handles.\n\t */\n\treadonly version: string;\n}\n"]}
@@ -1,66 +0,0 @@
1
- /**
2
- * Interface for mapping between QTI version-specific element names and canonical forms.
3
- *
4
- * QTI 2.x uses camelCase (e.g., 'choiceInteraction', 'simpleChoice')
5
- * QTI 3.0 uses kebab-case with qti- prefix (e.g., 'qti-choice-interaction', 'qti-simple-choice')
6
- *
7
- * This abstraction allows the parser and player to work with both versions
8
- * by converting to/from a canonical lowercase form.
9
- */
10
- export interface ElementNameMapper {
11
- /**
12
- * Convert QTI-version-specific element name to canonical lowercase form.
13
- *
14
- * @param elementName - The element name as it appears in the XML
15
- * @returns Canonical lowercase name for internal processing
16
- *
17
- * @example
18
- * // QTI 2.x
19
- * toCanonical('choiceInteraction') // => 'choiceinteraction'
20
- * toCanonical('simpleChoice') // => 'simplechoice'
21
- *
22
- * @example
23
- * // QTI 3.0
24
- * toCanonical('qti-choice-interaction') // => 'choiceinteraction'
25
- * toCanonical('qti-simple-choice') // => 'simplechoice'
26
- */
27
- toCanonical(elementName: string): string;
28
- /**
29
- * Convert canonical name back to version-specific form.
30
- *
31
- * @param canonicalName - Lowercase canonical name
32
- * @returns Version-specific element name
33
- *
34
- * @example
35
- * // QTI 2.x
36
- * toNative('choiceinteraction') // => 'choiceInteraction'
37
- * toNative('simplechoice') // => 'simpleChoice'
38
- *
39
- * @example
40
- * // QTI 3.0
41
- * toNative('choiceinteraction') // => 'qti-choice-interaction'
42
- * toNative('simplechoice') // => 'qti-simple-choice'
43
- */
44
- toNative(canonicalName: string): string;
45
- /**
46
- * Check if element name matches expected pattern for this QTI version.
47
- *
48
- * @param elementName - Element name to validate
49
- * @returns true if valid for this version
50
- *
51
- * @example
52
- * // QTI 2.x mapper
53
- * isValidElementName('choiceInteraction') // => true
54
- * isValidElementName('qti-choice-interaction') // => false
55
- *
56
- * @example
57
- * // QTI 3.0 mapper
58
- * isValidElementName('qti-choice-interaction') // => true
59
- * isValidElementName('choiceInteraction') // => false
60
- */
61
- isValidElementName(elementName: string): boolean;
62
- /**
63
- * Get the QTI version this mapper handles.
64
- */
65
- readonly version: string;
66
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ElementNameMapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ElementNameMapper.js","sourceRoot":"","sources":["../../src/element-mapper/ElementNameMapper.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Interface for mapping between QTI version-specific element names and canonical forms.\n *\n * QTI 2.x uses camelCase (e.g., 'choiceInteraction', 'simpleChoice')\n * QTI 3.0 uses kebab-case with qti- prefix (e.g., 'qti-choice-interaction', 'qti-simple-choice')\n *\n * This abstraction allows the parser and player to work with both versions\n * by converting to/from a canonical lowercase form.\n */\nexport interface ElementNameMapper {\n\t/**\n\t * Convert QTI-version-specific element name to canonical lowercase form.\n\t *\n\t * @param elementName - The element name as it appears in the XML\n\t * @returns Canonical lowercase name for internal processing\n\t *\n\t * @example\n\t * // QTI 2.x\n\t * toCanonical('choiceInteraction') // => 'choiceinteraction'\n\t * toCanonical('simpleChoice') // => 'simplechoice'\n\t *\n\t * @example\n\t * // QTI 3.0\n\t * toCanonical('qti-choice-interaction') // => 'choiceinteraction'\n\t * toCanonical('qti-simple-choice') // => 'simplechoice'\n\t */\n\ttoCanonical(elementName: string): string;\n\n\t/**\n\t * Convert canonical name back to version-specific form.\n\t *\n\t * @param canonicalName - Lowercase canonical name\n\t * @returns Version-specific element name\n\t *\n\t * @example\n\t * // QTI 2.x\n\t * toNative('choiceinteraction') // => 'choiceInteraction'\n\t * toNative('simplechoice') // => 'simpleChoice'\n\t *\n\t * @example\n\t * // QTI 3.0\n\t * toNative('choiceinteraction') // => 'qti-choice-interaction'\n\t * toNative('simplechoice') // => 'qti-simple-choice'\n\t */\n\ttoNative(canonicalName: string): string;\n\n\t/**\n\t * Check if element name matches expected pattern for this QTI version.\n\t *\n\t * @param elementName - Element name to validate\n\t * @returns true if valid for this version\n\t *\n\t * @example\n\t * // QTI 2.x mapper\n\t * isValidElementName('choiceInteraction') // => true\n\t * isValidElementName('qti-choice-interaction') // => false\n\t *\n\t * @example\n\t * // QTI 3.0 mapper\n\t * isValidElementName('qti-choice-interaction') // => true\n\t * isValidElementName('choiceInteraction') // => false\n\t */\n\tisValidElementName(elementName: string): boolean;\n\n\t/**\n\t * Get the QTI version this mapper handles.\n\t */\n\treadonly version: string;\n}\n"]}
@@ -1,27 +0,0 @@
1
- import type { AttributeNameMapper } from './AttributeNameMapper.js';
2
- /**
3
- * QTI 2.x attribute name mapper.
4
- *
5
- * QTI 2.x uses camelCase for all attribute names, so this mapper
6
- * is essentially a pass-through that validates camelCase format.
7
- *
8
- * @example
9
- * const mapper = new Qti2xAttributeNameMapper();
10
- * mapper.toCanonical('responseIdentifier'); // => 'responseIdentifier'
11
- * mapper.toNative('maxChoices'); // => 'maxChoices'
12
- */
13
- export declare class Qti2xAttributeNameMapper implements AttributeNameMapper {
14
- readonly version = "2.x";
15
- /**
16
- * For QTI 2.x, attributes are already in camelCase (canonical form).
17
- */
18
- toCanonical(attributeName: string): string;
19
- /**
20
- * For QTI 2.x, attributes are already in camelCase (native form).
21
- */
22
- toNative(canonicalName: string): string;
23
- /**
24
- * Check if attribute name is valid camelCase (no hyphens).
25
- */
26
- isValidAttributeName(attributeName: string): boolean;
27
- }
@@ -1,38 +0,0 @@
1
- /**
2
- * QTI 2.x attribute name mapper.
3
- *
4
- * QTI 2.x uses camelCase for all attribute names, so this mapper
5
- * is essentially a pass-through that validates camelCase format.
6
- *
7
- * @example
8
- * const mapper = new Qti2xAttributeNameMapper();
9
- * mapper.toCanonical('responseIdentifier'); // => 'responseIdentifier'
10
- * mapper.toNative('maxChoices'); // => 'maxChoices'
11
- */
12
- export class Qti2xAttributeNameMapper {
13
- version = '2.x';
14
- /**
15
- * For QTI 2.x, attributes are already in camelCase (canonical form).
16
- */
17
- toCanonical(attributeName) {
18
- return attributeName;
19
- }
20
- /**
21
- * For QTI 2.x, attributes are already in camelCase (native form).
22
- */
23
- toNative(canonicalName) {
24
- return canonicalName;
25
- }
26
- /**
27
- * Check if attribute name is valid camelCase (no hyphens).
28
- */
29
- isValidAttributeName(attributeName) {
30
- // QTI 2.x attributes should not contain hyphens
31
- // Exception: XML standard attributes like xml:lang, xml:base
32
- if (attributeName.startsWith('xml:') || attributeName.startsWith('xmlns')) {
33
- return true;
34
- }
35
- return !attributeName.includes('-');
36
- }
37
- }
38
- //# sourceMappingURL=Qti2xAttributeNameMapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Qti2xAttributeNameMapper.js","sourceRoot":"","sources":["../../src/element-mapper/Qti2xAttributeNameMapper.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,OAAO,wBAAwB;IAC3B,OAAO,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACH,WAAW,CAAC,aAAqB;QAChC,OAAO,aAAa,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,aAAqB;QAC7B,OAAO,aAAa,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,oBAAoB,CAAC,aAAqB;QACzC,gDAAgD;QAChD,6DAA6D;QAC7D,IAAI,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3E,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;CACD","sourcesContent":["import type { AttributeNameMapper } from './AttributeNameMapper.js';\n\n/**\n * QTI 2.x attribute name mapper.\n *\n * QTI 2.x uses camelCase for all attribute names, so this mapper\n * is essentially a pass-through that validates camelCase format.\n *\n * @example\n * const mapper = new Qti2xAttributeNameMapper();\n * mapper.toCanonical('responseIdentifier'); // => 'responseIdentifier'\n * mapper.toNative('maxChoices'); // => 'maxChoices'\n */\nexport class Qti2xAttributeNameMapper implements AttributeNameMapper {\n\treadonly version = '2.x';\n\n\t/**\n\t * For QTI 2.x, attributes are already in camelCase (canonical form).\n\t */\n\ttoCanonical(attributeName: string): string {\n\t\treturn attributeName;\n\t}\n\n\t/**\n\t * For QTI 2.x, attributes are already in camelCase (native form).\n\t */\n\ttoNative(canonicalName: string): string {\n\t\treturn canonicalName;\n\t}\n\n\t/**\n\t * Check if attribute name is valid camelCase (no hyphens).\n\t */\n\tisValidAttributeName(attributeName: string): boolean {\n\t\t// QTI 2.x attributes should not contain hyphens\n\t\t// Exception: XML standard attributes like xml:lang, xml:base\n\t\tif (attributeName.startsWith('xml:') || attributeName.startsWith('xmlns')) {\n\t\t\treturn true;\n\t\t}\n\t\treturn !attributeName.includes('-');\n\t}\n}\n"]}
@@ -1,37 +0,0 @@
1
- import type { ElementNameMapper } from './ElementNameMapper.js';
2
- /**
3
- * Element name mapper for QTI 2.x (versions 2.0, 2.1, 2.2).
4
- *
5
- * QTI 2.x uses camelCase element names:
6
- * - assessmentItem, itemBody, responseDeclaration
7
- * - choiceInteraction, simpleChoice
8
- * - responseProcessing, setOutcomeValue
9
- *
10
- * This mapper converts to/from lowercase canonical form for internal processing.
11
- */
12
- export declare class Qti2xElementNameMapper implements ElementNameMapper {
13
- readonly version = "2.x";
14
- /**
15
- * Convert QTI 2.x camelCase name to canonical lowercase.
16
- * @param elementName - camelCase element name
17
- * @returns lowercase canonical name
18
- */
19
- toCanonical(elementName: string): string;
20
- /**
21
- * Convert canonical lowercase to QTI 2.x camelCase.
22
- * Note: This is a best-effort conversion. The original casing
23
- * should be preserved when possible by the parser.
24
- *
25
- * @param canonicalName - lowercase canonical name
26
- * @returns camelCase element name
27
- */
28
- toNative(canonicalName: string): string;
29
- /**
30
- * Validate QTI 2.x element name pattern.
31
- * QTI 2.x uses camelCase starting with lowercase letter.
32
- *
33
- * @param elementName - Element name to validate
34
- * @returns true if valid camelCase pattern
35
- */
36
- isValidElementName(elementName: string): boolean;
37
- }
@@ -1,47 +0,0 @@
1
- /**
2
- * Element name mapper for QTI 2.x (versions 2.0, 2.1, 2.2).
3
- *
4
- * QTI 2.x uses camelCase element names:
5
- * - assessmentItem, itemBody, responseDeclaration
6
- * - choiceInteraction, simpleChoice
7
- * - responseProcessing, setOutcomeValue
8
- *
9
- * This mapper converts to/from lowercase canonical form for internal processing.
10
- */
11
- export class Qti2xElementNameMapper {
12
- version = '2.x';
13
- /**
14
- * Convert QTI 2.x camelCase name to canonical lowercase.
15
- * @param elementName - camelCase element name
16
- * @returns lowercase canonical name
17
- */
18
- toCanonical(elementName) {
19
- return elementName.toLowerCase();
20
- }
21
- /**
22
- * Convert canonical lowercase to QTI 2.x camelCase.
23
- * Note: This is a best-effort conversion. The original casing
24
- * should be preserved when possible by the parser.
25
- *
26
- * @param canonicalName - lowercase canonical name
27
- * @returns camelCase element name
28
- */
29
- toNative(canonicalName) {
30
- // For QTI 2.x, we can return lowercase since XML is case-insensitive
31
- // and our parser uses case-insensitive matching anyway
32
- return canonicalName;
33
- }
34
- /**
35
- * Validate QTI 2.x element name pattern.
36
- * QTI 2.x uses camelCase starting with lowercase letter.
37
- *
38
- * @param elementName - Element name to validate
39
- * @returns true if valid camelCase pattern
40
- */
41
- isValidElementName(elementName) {
42
- // QTI 2.x: starts with lowercase, can contain uppercase letters and numbers
43
- // Examples: assessmentItem, choiceInteraction, simpleChoice, html5div
44
- return /^[a-z][a-zA-Z0-9]*$/.test(elementName);
45
- }
46
- }
47
- //# sourceMappingURL=Qti2xElementNameMapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Qti2xElementNameMapper.js","sourceRoot":"","sources":["../../src/element-mapper/Qti2xElementNameMapper.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,OAAO,sBAAsB;IACzB,OAAO,GAAG,KAAK,CAAC;IAEzB;;;;OAIG;IACH,WAAW,CAAC,WAAmB;QAC9B,OAAO,WAAW,CAAC,WAAW,EAAE,CAAC;IAClC,CAAC;IAED;;;;;;;OAOG;IACH,QAAQ,CAAC,aAAqB;QAC7B,qEAAqE;QACrE,uDAAuD;QACvD,OAAO,aAAa,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACH,kBAAkB,CAAC,WAAmB;QACrC,4EAA4E;QAC5E,sEAAsE;QACtE,OAAO,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC;CACD","sourcesContent":["import type { ElementNameMapper } from './ElementNameMapper.js';\n\n/**\n * Element name mapper for QTI 2.x (versions 2.0, 2.1, 2.2).\n *\n * QTI 2.x uses camelCase element names:\n * - assessmentItem, itemBody, responseDeclaration\n * - choiceInteraction, simpleChoice\n * - responseProcessing, setOutcomeValue\n *\n * This mapper converts to/from lowercase canonical form for internal processing.\n */\nexport class Qti2xElementNameMapper implements ElementNameMapper {\n\treadonly version = '2.x';\n\n\t/**\n\t * Convert QTI 2.x camelCase name to canonical lowercase.\n\t * @param elementName - camelCase element name\n\t * @returns lowercase canonical name\n\t */\n\ttoCanonical(elementName: string): string {\n\t\treturn elementName.toLowerCase();\n\t}\n\n\t/**\n\t * Convert canonical lowercase to QTI 2.x camelCase.\n\t * Note: This is a best-effort conversion. The original casing\n\t * should be preserved when possible by the parser.\n\t *\n\t * @param canonicalName - lowercase canonical name\n\t * @returns camelCase element name\n\t */\n\ttoNative(canonicalName: string): string {\n\t\t// For QTI 2.x, we can return lowercase since XML is case-insensitive\n\t\t// and our parser uses case-insensitive matching anyway\n\t\treturn canonicalName;\n\t}\n\n\t/**\n\t * Validate QTI 2.x element name pattern.\n\t * QTI 2.x uses camelCase starting with lowercase letter.\n\t *\n\t * @param elementName - Element name to validate\n\t * @returns true if valid camelCase pattern\n\t */\n\tisValidElementName(elementName: string): boolean {\n\t\t// QTI 2.x: starts with lowercase, can contain uppercase letters and numbers\n\t\t// Examples: assessmentItem, choiceInteraction, simpleChoice, html5div\n\t\treturn /^[a-z][a-zA-Z0-9]*$/.test(elementName);\n\t}\n}\n"]}
@@ -1,40 +0,0 @@
1
- import type { AttributeNameMapper } from './AttributeNameMapper.js';
2
- /**
3
- * QTI 3.0 attribute name mapper.
4
- *
5
- * QTI 3.0 uses kebab-case for attribute names. This mapper converts
6
- * between kebab-case (QTI 3.0) and camelCase (internal canonical form).
7
- *
8
- * @example
9
- * const mapper = new Qti3AttributeNameMapper();
10
- * mapper.toCanonical('response-identifier'); // => 'responseIdentifier'
11
- * mapper.toCanonical('max-choices'); // => 'maxChoices'
12
- * mapper.toNative('responseIdentifier'); // => 'response-identifier'
13
- * mapper.toNative('maxChoices'); // => 'max-choices'
14
- */
15
- export declare class Qti3AttributeNameMapper implements AttributeNameMapper {
16
- readonly version = "3.0";
17
- private reverseMap;
18
- /**
19
- * Convert QTI 3.0 kebab-case attribute to canonical camelCase.
20
- */
21
- toCanonical(attributeName: string): string;
22
- /**
23
- * Convert canonical camelCase to QTI 3.0 kebab-case.
24
- */
25
- toNative(canonicalName: string): string;
26
- /**
27
- * Check if attribute name is valid kebab-case.
28
- */
29
- isValidAttributeName(attributeName: string): boolean;
30
- /**
31
- * Convert kebab-case to camelCase.
32
- * @private
33
- */
34
- private kebabToCamelCase;
35
- /**
36
- * Convert camelCase to kebab-case.
37
- * @private
38
- */
39
- private camelToKebabCase;
40
- }
@@ -1,87 +0,0 @@
1
- import { QTI3_ATTRIBUTE_TO_QTI2 } from './qti3-attribute-map.js';
2
- /**
3
- * QTI 3.0 attribute name mapper.
4
- *
5
- * QTI 3.0 uses kebab-case for attribute names. This mapper converts
6
- * between kebab-case (QTI 3.0) and camelCase (internal canonical form).
7
- *
8
- * @example
9
- * const mapper = new Qti3AttributeNameMapper();
10
- * mapper.toCanonical('response-identifier'); // => 'responseIdentifier'
11
- * mapper.toCanonical('max-choices'); // => 'maxChoices'
12
- * mapper.toNative('responseIdentifier'); // => 'response-identifier'
13
- * mapper.toNative('maxChoices'); // => 'max-choices'
14
- */
15
- export class Qti3AttributeNameMapper {
16
- version = '3.0';
17
- // Reverse mapping cache (camelCase -> kebab-case)
18
- reverseMap = null;
19
- /**
20
- * Convert QTI 3.0 kebab-case attribute to canonical camelCase.
21
- */
22
- toCanonical(attributeName) {
23
- // Direct lookup
24
- const canonical = QTI3_ATTRIBUTE_TO_QTI2.get(attributeName);
25
- if (canonical) {
26
- return canonical;
27
- }
28
- // If already in camelCase (no hyphens), return as-is
29
- if (!attributeName.includes('-')) {
30
- return attributeName;
31
- }
32
- // Fallback: convert kebab-case to camelCase programmatically
33
- return this.kebabToCamelCase(attributeName);
34
- }
35
- /**
36
- * Convert canonical camelCase to QTI 3.0 kebab-case.
37
- */
38
- toNative(canonicalName) {
39
- // Build reverse map on first use
40
- if (!this.reverseMap) {
41
- this.reverseMap = new Map();
42
- for (const [kebab, camel] of QTI3_ATTRIBUTE_TO_QTI2) {
43
- this.reverseMap.set(camel, kebab);
44
- }
45
- }
46
- // Direct lookup
47
- const native = this.reverseMap.get(canonicalName);
48
- if (native) {
49
- return native;
50
- }
51
- // If already in kebab-case, return as-is
52
- if (canonicalName.includes('-')) {
53
- return canonicalName;
54
- }
55
- // Fallback: convert camelCase to kebab-case programmatically
56
- return this.camelToKebabCase(canonicalName);
57
- }
58
- /**
59
- * Check if attribute name is valid kebab-case.
60
- */
61
- isValidAttributeName(attributeName) {
62
- // Standard XML attributes are always valid
63
- if (attributeName.startsWith('xml:') ||
64
- attributeName.startsWith('xmlns') ||
65
- attributeName === 'id') {
66
- return true;
67
- }
68
- // QTI 3.0 attributes should be kebab-case (lowercase with hyphens)
69
- // or simple lowercase (like 'shuffle', 'type', 'value')
70
- return /^[a-z][a-z0-9-]*$/.test(attributeName);
71
- }
72
- /**
73
- * Convert kebab-case to camelCase.
74
- * @private
75
- */
76
- kebabToCamelCase(str) {
77
- return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
78
- }
79
- /**
80
- * Convert camelCase to kebab-case.
81
- * @private
82
- */
83
- camelToKebabCase(str) {
84
- return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
85
- }
86
- }
87
- //# sourceMappingURL=Qti3AttributeNameMapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Qti3AttributeNameMapper.js","sourceRoot":"","sources":["../../src/element-mapper/Qti3AttributeNameMapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,uBAAuB;IAC1B,OAAO,GAAG,KAAK,CAAC;IAEzB,kDAAkD;IAC1C,UAAU,GAA+B,IAAI,CAAC;IAEtD;;OAEG;IACH,WAAW,CAAC,aAAqB;QAChC,gBAAgB;QAChB,MAAM,SAAS,GAAG,sBAAsB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAC5D,IAAI,SAAS,EAAE,CAAC;YACf,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,qDAAqD;QACrD,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAClC,OAAO,aAAa,CAAC;QACtB,CAAC;QAED,6DAA6D;QAC7D,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,aAAqB;QAC7B,iCAAiC;QACjC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACtB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;YAC5B,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,sBAAsB,EAAE,CAAC;gBACrD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACnC,CAAC;QACF,CAAC;QAED,gBAAgB;QAChB,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAClD,IAAI,MAAM,EAAE,CAAC;YACZ,OAAO,MAAM,CAAC;QACf,CAAC;QAED,yCAAyC;QACzC,IAAI,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,aAAa,CAAC;QACtB,CAAC;QAED,6DAA6D;QAC7D,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,oBAAoB,CAAC,aAAqB;QACzC,2CAA2C;QAC3C,IACC,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC;YAChC,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC;YACjC,aAAa,KAAK,IAAI,EACrB,CAAC;YACF,OAAO,IAAI,CAAC;QACb,CAAC;QAED,mEAAmE;QACnE,wDAAwD;QACxD,OAAO,mBAAmB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAChD,CAAC;IAED;;;OAGG;IACK,gBAAgB,CAAC,GAAW;QACnC,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;;;OAGG;IACK,gBAAgB,CAAC,GAAW;QACnC,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACtE,CAAC;CACD","sourcesContent":["import type { AttributeNameMapper } from './AttributeNameMapper.js';\nimport { QTI3_ATTRIBUTE_TO_QTI2 } from './qti3-attribute-map.js';\n\n/**\n * QTI 3.0 attribute name mapper.\n *\n * QTI 3.0 uses kebab-case for attribute names. This mapper converts\n * between kebab-case (QTI 3.0) and camelCase (internal canonical form).\n *\n * @example\n * const mapper = new Qti3AttributeNameMapper();\n * mapper.toCanonical('response-identifier'); // => 'responseIdentifier'\n * mapper.toCanonical('max-choices'); // => 'maxChoices'\n * mapper.toNative('responseIdentifier'); // => 'response-identifier'\n * mapper.toNative('maxChoices'); // => 'max-choices'\n */\nexport class Qti3AttributeNameMapper implements AttributeNameMapper {\n\treadonly version = '3.0';\n\n\t// Reverse mapping cache (camelCase -> kebab-case)\n\tprivate reverseMap: Map<string, string> | null = null;\n\n\t/**\n\t * Convert QTI 3.0 kebab-case attribute to canonical camelCase.\n\t */\n\ttoCanonical(attributeName: string): string {\n\t\t// Direct lookup\n\t\tconst canonical = QTI3_ATTRIBUTE_TO_QTI2.get(attributeName);\n\t\tif (canonical) {\n\t\t\treturn canonical;\n\t\t}\n\n\t\t// If already in camelCase (no hyphens), return as-is\n\t\tif (!attributeName.includes('-')) {\n\t\t\treturn attributeName;\n\t\t}\n\n\t\t// Fallback: convert kebab-case to camelCase programmatically\n\t\treturn this.kebabToCamelCase(attributeName);\n\t}\n\n\t/**\n\t * Convert canonical camelCase to QTI 3.0 kebab-case.\n\t */\n\ttoNative(canonicalName: string): string {\n\t\t// Build reverse map on first use\n\t\tif (!this.reverseMap) {\n\t\t\tthis.reverseMap = new Map();\n\t\t\tfor (const [kebab, camel] of QTI3_ATTRIBUTE_TO_QTI2) {\n\t\t\t\tthis.reverseMap.set(camel, kebab);\n\t\t\t}\n\t\t}\n\n\t\t// Direct lookup\n\t\tconst native = this.reverseMap.get(canonicalName);\n\t\tif (native) {\n\t\t\treturn native;\n\t\t}\n\n\t\t// If already in kebab-case, return as-is\n\t\tif (canonicalName.includes('-')) {\n\t\t\treturn canonicalName;\n\t\t}\n\n\t\t// Fallback: convert camelCase to kebab-case programmatically\n\t\treturn this.camelToKebabCase(canonicalName);\n\t}\n\n\t/**\n\t * Check if attribute name is valid kebab-case.\n\t */\n\tisValidAttributeName(attributeName: string): boolean {\n\t\t// Standard XML attributes are always valid\n\t\tif (\n\t\t\tattributeName.startsWith('xml:') ||\n\t\t\tattributeName.startsWith('xmlns') ||\n\t\t\tattributeName === 'id'\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// QTI 3.0 attributes should be kebab-case (lowercase with hyphens)\n\t\t// or simple lowercase (like 'shuffle', 'type', 'value')\n\t\treturn /^[a-z][a-z0-9-]*$/.test(attributeName);\n\t}\n\n\t/**\n\t * Convert kebab-case to camelCase.\n\t * @private\n\t */\n\tprivate kebabToCamelCase(str: string): string {\n\t\treturn str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n\t}\n\n\t/**\n\t * Convert camelCase to kebab-case.\n\t * @private\n\t */\n\tprivate camelToKebabCase(str: string): string {\n\t\treturn str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n\t}\n}\n"]}
@@ -1,14 +0,0 @@
1
- import type { ElementNameMapper } from './ElementNameMapper.js';
2
- /**
3
- * Element name mapper for QTI 3.0.
4
- *
5
- * QTI-defined elements use kebab-case with a `qti-` prefix. HTML, MathML,
6
- * SVG, and extension vocabularies retain their native names.
7
- */
8
- export declare class Qti3ElementNameMapper implements ElementNameMapper {
9
- readonly version = "3.0";
10
- private readonly PREFIX;
11
- toCanonical(elementName: string): string;
12
- toNative(canonicalName: string): string;
13
- isValidElementName(elementName: string): boolean;
14
- }