@pie-qti/item-player 0.1.5 → 0.1.6

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 (432) hide show
  1. package/dist/core/ComponentRegistry.d.ts +5 -4
  2. package/dist/core/ComponentRegistry.d.ts.map +1 -1
  3. package/dist/core/ComponentRegistry.js +11 -4
  4. package/dist/core/ItemRenderer.d.ts.map +1 -1
  5. package/dist/core/ItemRenderer.js +5 -18
  6. package/dist/core/Player.d.ts +2 -2
  7. package/dist/core/Player.d.ts.map +1 -1
  8. package/dist/core/Player.js +46 -147
  9. package/dist/document/AssessmentItemDocument.d.ts +42 -0
  10. package/dist/document/AssessmentItemDocument.d.ts.map +1 -0
  11. package/dist/document/AssessmentItemDocument.js +116 -0
  12. package/dist/element.js +2515 -2294
  13. package/dist/element.js.map +1 -1
  14. package/dist/extraction/extractors/associateExtractor.d.ts +1 -28
  15. package/dist/extraction/extractors/associateExtractor.d.ts.map +1 -1
  16. package/dist/extraction/extractors/associateExtractor.js +1 -97
  17. package/dist/extraction/extractors/choiceExtractor.d.ts +1 -26
  18. package/dist/extraction/extractors/choiceExtractor.d.ts.map +1 -1
  19. package/dist/extraction/extractors/choiceExtractor.js +1 -93
  20. package/dist/extraction/extractors/customExtractor.d.ts +1 -19
  21. package/dist/extraction/extractors/customExtractor.d.ts.map +1 -1
  22. package/dist/extraction/extractors/customExtractor.js +1 -51
  23. package/dist/extraction/extractors/drawingExtractor.d.ts +1 -29
  24. package/dist/extraction/extractors/drawingExtractor.d.ts.map +1 -1
  25. package/dist/extraction/extractors/drawingExtractor.js +1 -78
  26. package/dist/extraction/extractors/endAttemptExtractor.d.ts +1 -19
  27. package/dist/extraction/extractors/endAttemptExtractor.d.ts.map +1 -1
  28. package/dist/extraction/extractors/endAttemptExtractor.js +1 -53
  29. package/dist/extraction/extractors/extendedTextExtractor.d.ts +1 -20
  30. package/dist/extraction/extractors/extendedTextExtractor.d.ts.map +1 -1
  31. package/dist/extraction/extractors/extendedTextExtractor.js +1 -63
  32. package/dist/extraction/extractors/gapMatchExtractor.d.ts +1 -28
  33. package/dist/extraction/extractors/gapMatchExtractor.d.ts.map +1 -1
  34. package/dist/extraction/extractors/gapMatchExtractor.js +1 -155
  35. package/dist/extraction/extractors/graphicAssociateExtractor.d.ts +1 -40
  36. package/dist/extraction/extractors/graphicAssociateExtractor.d.ts.map +1 -1
  37. package/dist/extraction/extractors/graphicAssociateExtractor.js +1 -143
  38. package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts +1 -52
  39. package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts.map +1 -1
  40. package/dist/extraction/extractors/graphicGapMatchExtractor.js +1 -205
  41. package/dist/extraction/extractors/graphicOrderExtractor.d.ts +1 -36
  42. package/dist/extraction/extractors/graphicOrderExtractor.d.ts.map +1 -1
  43. package/dist/extraction/extractors/graphicOrderExtractor.js +1 -121
  44. package/dist/extraction/extractors/hotspotExtractor.d.ts +1 -37
  45. package/dist/extraction/extractors/hotspotExtractor.d.ts.map +1 -1
  46. package/dist/extraction/extractors/hotspotExtractor.js +1 -159
  47. package/dist/extraction/extractors/hottextExtractor.d.ts +1 -25
  48. package/dist/extraction/extractors/hottextExtractor.d.ts.map +1 -1
  49. package/dist/extraction/extractors/hottextExtractor.js +1 -128
  50. package/dist/extraction/extractors/index.d.ts +5 -59
  51. package/dist/extraction/extractors/index.d.ts.map +1 -1
  52. package/dist/extraction/extractors/index.js +5 -85
  53. package/dist/extraction/extractors/inlineChoiceExtractor.d.ts +1 -24
  54. package/dist/extraction/extractors/inlineChoiceExtractor.d.ts.map +1 -1
  55. package/dist/extraction/extractors/inlineChoiceExtractor.js +1 -80
  56. package/dist/extraction/extractors/matchExtractor.d.ts +1 -36
  57. package/dist/extraction/extractors/matchExtractor.d.ts.map +1 -1
  58. package/dist/extraction/extractors/matchExtractor.js +1 -160
  59. package/dist/extraction/extractors/mediaExtractor.d.ts +1 -32
  60. package/dist/extraction/extractors/mediaExtractor.d.ts.map +1 -1
  61. package/dist/extraction/extractors/mediaExtractor.js +1 -125
  62. package/dist/extraction/extractors/orderExtractor.d.ts +1 -27
  63. package/dist/extraction/extractors/orderExtractor.d.ts.map +1 -1
  64. package/dist/extraction/extractors/orderExtractor.js +1 -90
  65. package/dist/extraction/extractors/portableCustomExtractor.d.ts +1 -13
  66. package/dist/extraction/extractors/portableCustomExtractor.d.ts.map +1 -1
  67. package/dist/extraction/extractors/portableCustomExtractor.js +1 -96
  68. package/dist/extraction/extractors/positionObjectExtractor.d.ts +1 -58
  69. package/dist/extraction/extractors/positionObjectExtractor.d.ts.map +1 -1
  70. package/dist/extraction/extractors/positionObjectExtractor.js +1 -191
  71. package/dist/extraction/extractors/selectPointExtractor.d.ts +1 -30
  72. package/dist/extraction/extractors/selectPointExtractor.d.ts.map +1 -1
  73. package/dist/extraction/extractors/selectPointExtractor.js +1 -109
  74. package/dist/extraction/extractors/sliderExtractor.d.ts +1 -23
  75. package/dist/extraction/extractors/sliderExtractor.d.ts.map +1 -1
  76. package/dist/extraction/extractors/sliderExtractor.js +1 -73
  77. package/dist/extraction/extractors/textEntryExtractor.d.ts +1 -20
  78. package/dist/extraction/extractors/textEntryExtractor.d.ts.map +1 -1
  79. package/dist/extraction/extractors/textEntryExtractor.js +1 -54
  80. package/dist/extraction/extractors/uploadExtractor.d.ts +1 -19
  81. package/dist/extraction/extractors/uploadExtractor.d.ts.map +1 -1
  82. package/dist/extraction/extractors/uploadExtractor.js +1 -59
  83. package/dist/extraction/index.d.ts +1 -1
  84. package/dist/extraction/index.d.ts.map +1 -1
  85. package/dist/extraction/index.js +2 -2
  86. package/dist/extraction/interactionExtractionPipeline.d.ts +13 -0
  87. package/dist/extraction/interactionExtractionPipeline.d.ts.map +1 -0
  88. package/dist/extraction/interactionExtractionPipeline.js +39 -0
  89. package/dist/extraction/interactionSecurity.d.ts +4 -0
  90. package/dist/extraction/interactionSecurity.d.ts.map +1 -0
  91. package/dist/extraction/interactionSecurity.js +48 -0
  92. package/dist/index.d.ts +1 -1
  93. package/dist/index.d.ts.map +1 -1
  94. package/dist/index.js +3 -3
  95. package/dist/interactions/associate/extractor.d.ts +29 -0
  96. package/dist/interactions/associate/extractor.d.ts.map +1 -0
  97. package/dist/interactions/associate/extractor.js +97 -0
  98. package/dist/interactions/associate/index.d.ts +3 -0
  99. package/dist/interactions/associate/index.d.ts.map +1 -0
  100. package/dist/interactions/associate/index.js +1 -0
  101. package/dist/interactions/associate/types.d.ts +2 -0
  102. package/dist/interactions/associate/types.d.ts.map +1 -0
  103. package/dist/interactions/associate/types.js +1 -0
  104. package/dist/interactions/choice/extractor.d.ts +27 -0
  105. package/dist/interactions/choice/extractor.d.ts.map +1 -0
  106. package/dist/interactions/choice/extractor.js +93 -0
  107. package/dist/interactions/choice/index.d.ts +3 -0
  108. package/dist/interactions/choice/index.d.ts.map +1 -0
  109. package/dist/interactions/choice/index.js +1 -0
  110. package/dist/interactions/choice/types.d.ts +2 -0
  111. package/dist/interactions/choice/types.d.ts.map +1 -0
  112. package/dist/interactions/choice/types.js +1 -0
  113. package/dist/interactions/custom/extractor.d.ts +20 -0
  114. package/dist/interactions/custom/extractor.d.ts.map +1 -0
  115. package/dist/interactions/custom/extractor.js +51 -0
  116. package/dist/interactions/custom/index.d.ts +3 -0
  117. package/dist/interactions/custom/index.d.ts.map +1 -0
  118. package/dist/interactions/custom/index.js +1 -0
  119. package/dist/interactions/custom/types.d.ts +2 -0
  120. package/dist/interactions/custom/types.d.ts.map +1 -0
  121. package/dist/interactions/custom/types.js +1 -0
  122. package/dist/interactions/drawing/extractor.d.ts +30 -0
  123. package/dist/interactions/drawing/extractor.d.ts.map +1 -0
  124. package/dist/interactions/drawing/extractor.js +78 -0
  125. package/dist/interactions/drawing/index.d.ts +3 -0
  126. package/dist/interactions/drawing/index.d.ts.map +1 -0
  127. package/dist/interactions/drawing/index.js +1 -0
  128. package/dist/interactions/drawing/types.d.ts +2 -0
  129. package/dist/interactions/drawing/types.d.ts.map +1 -0
  130. package/dist/interactions/drawing/types.js +1 -0
  131. package/dist/interactions/end-attempt/extractor.d.ts +20 -0
  132. package/dist/interactions/end-attempt/extractor.d.ts.map +1 -0
  133. package/dist/interactions/end-attempt/extractor.js +53 -0
  134. package/dist/interactions/end-attempt/index.d.ts +3 -0
  135. package/dist/interactions/end-attempt/index.d.ts.map +1 -0
  136. package/dist/interactions/end-attempt/index.js +1 -0
  137. package/dist/interactions/end-attempt/types.d.ts +2 -0
  138. package/dist/interactions/end-attempt/types.d.ts.map +1 -0
  139. package/dist/interactions/end-attempt/types.js +1 -0
  140. package/dist/interactions/extended-text/extractor.d.ts +21 -0
  141. package/dist/interactions/extended-text/extractor.d.ts.map +1 -0
  142. package/dist/interactions/extended-text/extractor.js +63 -0
  143. package/dist/interactions/extended-text/index.d.ts +3 -0
  144. package/dist/interactions/extended-text/index.d.ts.map +1 -0
  145. package/dist/interactions/extended-text/index.js +1 -0
  146. package/dist/interactions/extended-text/types.d.ts +2 -0
  147. package/dist/interactions/extended-text/types.d.ts.map +1 -0
  148. package/dist/interactions/extended-text/types.js +1 -0
  149. package/dist/interactions/gap-match/extractor.d.ts +29 -0
  150. package/dist/interactions/gap-match/extractor.d.ts.map +1 -0
  151. package/dist/interactions/gap-match/extractor.js +155 -0
  152. package/dist/interactions/gap-match/index.d.ts +3 -0
  153. package/dist/interactions/gap-match/index.d.ts.map +1 -0
  154. package/dist/interactions/gap-match/index.js +1 -0
  155. package/dist/interactions/gap-match/types.d.ts +2 -0
  156. package/dist/interactions/gap-match/types.d.ts.map +1 -0
  157. package/dist/interactions/gap-match/types.js +1 -0
  158. package/dist/interactions/graphic-associate/extractor.d.ts +41 -0
  159. package/dist/interactions/graphic-associate/extractor.d.ts.map +1 -0
  160. package/dist/interactions/graphic-associate/extractor.js +143 -0
  161. package/dist/interactions/graphic-associate/index.d.ts +3 -0
  162. package/dist/interactions/graphic-associate/index.d.ts.map +1 -0
  163. package/dist/interactions/graphic-associate/index.js +1 -0
  164. package/dist/interactions/graphic-associate/types.d.ts +2 -0
  165. package/dist/interactions/graphic-associate/types.d.ts.map +1 -0
  166. package/dist/interactions/graphic-associate/types.js +1 -0
  167. package/dist/interactions/graphic-gap-match/extractor.d.ts +53 -0
  168. package/dist/interactions/graphic-gap-match/extractor.d.ts.map +1 -0
  169. package/dist/interactions/graphic-gap-match/extractor.js +205 -0
  170. package/dist/interactions/graphic-gap-match/index.d.ts +3 -0
  171. package/dist/interactions/graphic-gap-match/index.d.ts.map +1 -0
  172. package/dist/interactions/graphic-gap-match/index.js +1 -0
  173. package/dist/interactions/graphic-gap-match/types.d.ts +2 -0
  174. package/dist/interactions/graphic-gap-match/types.d.ts.map +1 -0
  175. package/dist/interactions/graphic-gap-match/types.js +1 -0
  176. package/dist/interactions/graphic-order/extractor.d.ts +37 -0
  177. package/dist/interactions/graphic-order/extractor.d.ts.map +1 -0
  178. package/dist/interactions/graphic-order/extractor.js +121 -0
  179. package/dist/interactions/graphic-order/index.d.ts +3 -0
  180. package/dist/interactions/graphic-order/index.d.ts.map +1 -0
  181. package/dist/interactions/graphic-order/index.js +1 -0
  182. package/dist/interactions/graphic-order/types.d.ts +2 -0
  183. package/dist/interactions/graphic-order/types.d.ts.map +1 -0
  184. package/dist/interactions/graphic-order/types.js +1 -0
  185. package/dist/interactions/hotspot/extractor.d.ts +38 -0
  186. package/dist/interactions/hotspot/extractor.d.ts.map +1 -0
  187. package/dist/interactions/hotspot/extractor.js +159 -0
  188. package/dist/interactions/hotspot/index.d.ts +3 -0
  189. package/dist/interactions/hotspot/index.d.ts.map +1 -0
  190. package/dist/interactions/hotspot/index.js +1 -0
  191. package/dist/interactions/hotspot/types.d.ts +2 -0
  192. package/dist/interactions/hotspot/types.d.ts.map +1 -0
  193. package/dist/interactions/hotspot/types.js +1 -0
  194. package/dist/interactions/hottext/extractor.d.ts +26 -0
  195. package/dist/interactions/hottext/extractor.d.ts.map +1 -0
  196. package/dist/interactions/hottext/extractor.js +128 -0
  197. package/dist/interactions/hottext/index.d.ts +3 -0
  198. package/dist/interactions/hottext/index.d.ts.map +1 -0
  199. package/dist/interactions/hottext/index.js +1 -0
  200. package/dist/interactions/hottext/types.d.ts +2 -0
  201. package/dist/interactions/hottext/types.d.ts.map +1 -0
  202. package/dist/interactions/hottext/types.js +1 -0
  203. package/dist/interactions/index.d.ts +33 -0
  204. package/dist/interactions/index.d.ts.map +1 -0
  205. package/dist/interactions/index.js +30 -0
  206. package/dist/interactions/inline/index.d.ts +2 -0
  207. package/dist/interactions/inline/index.d.ts.map +1 -0
  208. package/dist/interactions/inline/index.js +1 -0
  209. package/dist/interactions/inline/render-plan.d.ts +19 -0
  210. package/dist/interactions/inline/render-plan.d.ts.map +1 -0
  211. package/dist/interactions/inline/render-plan.js +59 -0
  212. package/dist/interactions/inline-choice/extractor.d.ts +25 -0
  213. package/dist/interactions/inline-choice/extractor.d.ts.map +1 -0
  214. package/dist/interactions/inline-choice/extractor.js +80 -0
  215. package/dist/interactions/inline-choice/index.d.ts +3 -0
  216. package/dist/interactions/inline-choice/index.d.ts.map +1 -0
  217. package/dist/interactions/inline-choice/index.js +1 -0
  218. package/dist/interactions/inline-choice/types.d.ts +2 -0
  219. package/dist/interactions/inline-choice/types.d.ts.map +1 -0
  220. package/dist/interactions/inline-choice/types.js +1 -0
  221. package/dist/interactions/match/extractor.d.ts +37 -0
  222. package/dist/interactions/match/extractor.d.ts.map +1 -0
  223. package/dist/interactions/match/extractor.js +160 -0
  224. package/dist/interactions/match/index.d.ts +3 -0
  225. package/dist/interactions/match/index.d.ts.map +1 -0
  226. package/dist/interactions/match/index.js +1 -0
  227. package/dist/interactions/match/types.d.ts +2 -0
  228. package/dist/interactions/match/types.d.ts.map +1 -0
  229. package/dist/interactions/match/types.js +1 -0
  230. package/dist/interactions/media/extractor.d.ts +33 -0
  231. package/dist/interactions/media/extractor.d.ts.map +1 -0
  232. package/dist/interactions/media/extractor.js +125 -0
  233. package/dist/interactions/media/index.d.ts +3 -0
  234. package/dist/interactions/media/index.d.ts.map +1 -0
  235. package/dist/interactions/media/index.js +1 -0
  236. package/dist/interactions/media/types.d.ts +2 -0
  237. package/dist/interactions/media/types.d.ts.map +1 -0
  238. package/dist/interactions/media/types.js +1 -0
  239. package/dist/interactions/modules.d.ts +105 -0
  240. package/dist/interactions/modules.d.ts.map +1 -0
  241. package/dist/interactions/modules.js +86 -0
  242. package/dist/interactions/order/extractor.d.ts +28 -0
  243. package/dist/interactions/order/extractor.d.ts.map +1 -0
  244. package/dist/interactions/order/extractor.js +90 -0
  245. package/dist/interactions/order/index.d.ts +3 -0
  246. package/dist/interactions/order/index.d.ts.map +1 -0
  247. package/dist/interactions/order/index.js +1 -0
  248. package/dist/interactions/order/types.d.ts +2 -0
  249. package/dist/interactions/order/types.d.ts.map +1 -0
  250. package/dist/interactions/order/types.js +1 -0
  251. package/dist/interactions/portable-custom/extractor.d.ts +14 -0
  252. package/dist/interactions/portable-custom/extractor.d.ts.map +1 -0
  253. package/dist/interactions/portable-custom/extractor.js +96 -0
  254. package/dist/interactions/portable-custom/index.d.ts +3 -0
  255. package/dist/interactions/portable-custom/index.d.ts.map +1 -0
  256. package/dist/interactions/portable-custom/index.js +1 -0
  257. package/dist/interactions/portable-custom/types.d.ts +2 -0
  258. package/dist/interactions/portable-custom/types.d.ts.map +1 -0
  259. package/dist/interactions/portable-custom/types.js +1 -0
  260. package/dist/interactions/position-object/extractor.d.ts +59 -0
  261. package/dist/interactions/position-object/extractor.d.ts.map +1 -0
  262. package/dist/interactions/position-object/extractor.js +191 -0
  263. package/dist/interactions/position-object/index.d.ts +3 -0
  264. package/dist/interactions/position-object/index.d.ts.map +1 -0
  265. package/dist/interactions/position-object/index.js +1 -0
  266. package/dist/interactions/position-object/types.d.ts +2 -0
  267. package/dist/interactions/position-object/types.d.ts.map +1 -0
  268. package/dist/interactions/position-object/types.js +1 -0
  269. package/dist/interactions/select-point/extractor.d.ts +31 -0
  270. package/dist/interactions/select-point/extractor.d.ts.map +1 -0
  271. package/dist/interactions/select-point/extractor.js +109 -0
  272. package/dist/interactions/select-point/index.d.ts +3 -0
  273. package/dist/interactions/select-point/index.d.ts.map +1 -0
  274. package/dist/interactions/select-point/index.js +1 -0
  275. package/dist/interactions/select-point/types.d.ts +2 -0
  276. package/dist/interactions/select-point/types.d.ts.map +1 -0
  277. package/dist/interactions/select-point/types.js +1 -0
  278. package/dist/interactions/shared/index.d.ts +2 -0
  279. package/dist/interactions/shared/index.d.ts.map +1 -0
  280. package/dist/interactions/shared/index.js +1 -0
  281. package/dist/interactions/shared/types.d.ts +412 -0
  282. package/dist/interactions/shared/types.d.ts.map +1 -0
  283. package/dist/interactions/shared/types.js +7 -0
  284. package/dist/interactions/slider/extractor.d.ts +24 -0
  285. package/dist/interactions/slider/extractor.d.ts.map +1 -0
  286. package/dist/interactions/slider/extractor.js +73 -0
  287. package/dist/interactions/slider/index.d.ts +3 -0
  288. package/dist/interactions/slider/index.d.ts.map +1 -0
  289. package/dist/interactions/slider/index.js +1 -0
  290. package/dist/interactions/slider/types.d.ts +2 -0
  291. package/dist/interactions/slider/types.d.ts.map +1 -0
  292. package/dist/interactions/slider/types.js +1 -0
  293. package/dist/interactions/text-entry/extractor.d.ts +21 -0
  294. package/dist/interactions/text-entry/extractor.d.ts.map +1 -0
  295. package/dist/interactions/text-entry/extractor.js +54 -0
  296. package/dist/interactions/text-entry/index.d.ts +3 -0
  297. package/dist/interactions/text-entry/index.d.ts.map +1 -0
  298. package/dist/interactions/text-entry/index.js +1 -0
  299. package/dist/interactions/text-entry/types.d.ts +2 -0
  300. package/dist/interactions/text-entry/types.d.ts.map +1 -0
  301. package/dist/interactions/text-entry/types.js +1 -0
  302. package/dist/interactions/upload/extractor.d.ts +20 -0
  303. package/dist/interactions/upload/extractor.d.ts.map +1 -0
  304. package/dist/interactions/upload/extractor.js +59 -0
  305. package/dist/interactions/upload/index.d.ts +3 -0
  306. package/dist/interactions/upload/index.d.ts.map +1 -0
  307. package/dist/interactions/upload/index.js +1 -0
  308. package/dist/interactions/upload/types.d.ts +2 -0
  309. package/dist/interactions/upload/types.d.ts.map +1 -0
  310. package/dist/interactions/upload/types.js +1 -0
  311. package/dist/types/interactions.d.ts +4 -408
  312. package/dist/types/interactions.d.ts.map +1 -1
  313. package/dist/types/interactions.js +3 -3
  314. package/dist/web-components/QTIInteractionBase.d.ts +5 -5
  315. package/dist/web-components/QTIInteractionBase.d.ts.map +1 -1
  316. package/dist/web-components/QTIInteractionElement.d.ts +11 -8
  317. package/dist/web-components/QTIInteractionElement.d.ts.map +1 -1
  318. package/dist/web-components/index.d.ts +1 -1
  319. package/dist/web-components/index.d.ts.map +1 -1
  320. package/package.json +6 -6
  321. package/src/components/ItemBody.svelte +35 -173
  322. package/src/components/ItemPlayer.svelte +9 -5
  323. package/src/components/ModalFeedbackDisplay.svelte +15 -5
  324. package/src/core/ComponentRegistry.ts +22 -7
  325. package/src/core/Player.ts +48 -163
  326. package/src/document/AssessmentItemDocument.ts +178 -0
  327. package/src/extraction/extractors/associateExtractor.ts +1 -133
  328. package/src/extraction/extractors/choiceExtractor.ts +1 -121
  329. package/src/extraction/extractors/customExtractor.ts +1 -72
  330. package/src/extraction/extractors/drawingExtractor.ts +1 -113
  331. package/src/extraction/extractors/endAttemptExtractor.ts +1 -74
  332. package/src/extraction/extractors/extendedTextExtractor.ts +1 -89
  333. package/src/extraction/extractors/gapMatchExtractor.ts +1 -193
  334. package/src/extraction/extractors/graphicAssociateExtractor.ts +1 -192
  335. package/src/extraction/extractors/graphicGapMatchExtractor.ts +1 -257
  336. package/src/extraction/extractors/graphicOrderExtractor.ts +1 -162
  337. package/src/extraction/extractors/hotspotExtractor.ts +1 -208
  338. package/src/extraction/extractors/hottextExtractor.ts +1 -163
  339. package/src/extraction/extractors/index.ts +5 -111
  340. package/src/extraction/extractors/inlineChoiceExtractor.ts +1 -105
  341. package/src/extraction/extractors/matchExtractor.ts +1 -187
  342. package/src/extraction/extractors/mediaExtractor.ts +1 -168
  343. package/src/extraction/extractors/orderExtractor.ts +1 -120
  344. package/src/extraction/extractors/portableCustomExtractor.ts +1 -122
  345. package/src/extraction/extractors/positionObjectExtractor.ts +1 -243
  346. package/src/extraction/extractors/selectPointExtractor.ts +1 -143
  347. package/src/extraction/extractors/sliderExtractor.ts +1 -102
  348. package/src/extraction/extractors/textEntryExtractor.ts +1 -79
  349. package/src/extraction/extractors/uploadExtractor.ts +1 -81
  350. package/src/extraction/index.ts +1 -2
  351. package/src/extraction/interactionExtractionPipeline.ts +70 -0
  352. package/src/extraction/interactionSecurity.ts +60 -0
  353. package/src/index.ts +2 -7
  354. package/src/interactions/associate/extractor.ts +133 -0
  355. package/src/interactions/associate/index.ts +2 -0
  356. package/src/interactions/associate/types.ts +1 -0
  357. package/src/interactions/choice/extractor.ts +121 -0
  358. package/src/interactions/choice/index.ts +2 -0
  359. package/src/interactions/choice/types.ts +1 -0
  360. package/src/interactions/custom/extractor.ts +72 -0
  361. package/src/interactions/custom/index.ts +2 -0
  362. package/src/interactions/custom/types.ts +1 -0
  363. package/src/interactions/drawing/extractor.ts +113 -0
  364. package/src/interactions/drawing/index.ts +2 -0
  365. package/src/interactions/drawing/types.ts +1 -0
  366. package/src/interactions/end-attempt/extractor.ts +74 -0
  367. package/src/interactions/end-attempt/index.ts +2 -0
  368. package/src/interactions/end-attempt/types.ts +1 -0
  369. package/src/interactions/extended-text/extractor.ts +89 -0
  370. package/src/interactions/extended-text/index.ts +2 -0
  371. package/src/interactions/extended-text/types.ts +1 -0
  372. package/src/interactions/gap-match/extractor.ts +193 -0
  373. package/src/interactions/gap-match/index.ts +2 -0
  374. package/src/interactions/gap-match/types.ts +1 -0
  375. package/src/interactions/graphic-associate/extractor.ts +192 -0
  376. package/src/interactions/graphic-associate/index.ts +2 -0
  377. package/src/interactions/graphic-associate/types.ts +1 -0
  378. package/src/interactions/graphic-gap-match/extractor.ts +257 -0
  379. package/src/interactions/graphic-gap-match/index.ts +2 -0
  380. package/src/interactions/graphic-gap-match/types.ts +1 -0
  381. package/src/interactions/graphic-order/extractor.ts +162 -0
  382. package/src/interactions/graphic-order/index.ts +2 -0
  383. package/src/interactions/graphic-order/types.ts +1 -0
  384. package/src/interactions/hotspot/extractor.ts +208 -0
  385. package/src/interactions/hotspot/index.ts +2 -0
  386. package/src/interactions/hotspot/types.ts +1 -0
  387. package/src/interactions/hottext/extractor.ts +163 -0
  388. package/src/interactions/hottext/index.ts +2 -0
  389. package/src/interactions/hottext/types.ts +1 -0
  390. package/src/interactions/index.ts +52 -0
  391. package/src/interactions/inline/index.ts +1 -0
  392. package/src/interactions/inline/render-plan.ts +105 -0
  393. package/src/interactions/inline-choice/InlineChoice.svelte +57 -0
  394. package/src/interactions/inline-choice/extractor.ts +105 -0
  395. package/src/interactions/inline-choice/index.ts +2 -0
  396. package/src/interactions/inline-choice/types.ts +1 -0
  397. package/src/interactions/match/extractor.ts +187 -0
  398. package/src/interactions/match/index.ts +2 -0
  399. package/src/interactions/match/types.ts +1 -0
  400. package/src/interactions/media/extractor.ts +168 -0
  401. package/src/interactions/media/index.ts +2 -0
  402. package/src/interactions/media/types.ts +1 -0
  403. package/src/interactions/modules.ts +111 -0
  404. package/src/interactions/order/extractor.ts +120 -0
  405. package/src/interactions/order/index.ts +2 -0
  406. package/src/interactions/order/types.ts +1 -0
  407. package/src/interactions/portable-custom/extractor.ts +122 -0
  408. package/src/interactions/portable-custom/index.ts +2 -0
  409. package/src/interactions/portable-custom/types.ts +1 -0
  410. package/src/interactions/position-object/extractor.ts +243 -0
  411. package/src/interactions/position-object/index.ts +2 -0
  412. package/src/interactions/position-object/types.ts +1 -0
  413. package/src/interactions/select-point/extractor.ts +143 -0
  414. package/src/interactions/select-point/index.ts +2 -0
  415. package/src/interactions/select-point/types.ts +1 -0
  416. package/src/interactions/shared/index.ts +1 -0
  417. package/src/interactions/shared/types.ts +429 -0
  418. package/src/interactions/slider/extractor.ts +102 -0
  419. package/src/interactions/slider/index.ts +2 -0
  420. package/src/interactions/slider/types.ts +1 -0
  421. package/src/interactions/text-entry/InlineTextEntry.svelte +75 -0
  422. package/src/interactions/text-entry/extractor.ts +79 -0
  423. package/src/interactions/text-entry/index.ts +2 -0
  424. package/src/interactions/text-entry/types.ts +1 -0
  425. package/src/interactions/upload/extractor.ts +81 -0
  426. package/src/interactions/upload/index.ts +2 -0
  427. package/src/interactions/upload/types.ts +1 -0
  428. package/src/types/interactions.ts +4 -425
  429. package/src/web-components/QTIInteractionBase.ts +6 -5
  430. package/src/web-components/QTIInteractionElement.ts +15 -8
  431. package/src/web-components/index.ts +1 -0
  432. package/src/core/ItemRenderer.ts +0 -371
@@ -1,192 +1 @@
1
- /**
2
- * Standard QTI graphicAssociateInteraction extractor
3
- *
4
- * Extracts data from graphicAssociateInteraction elements (associate items on image)
5
- */
6
-
7
- import type { ElementExtractor } from '../types.js';
8
-
9
- /**
10
- * Image data for graphic associate interaction
11
- */
12
- export interface ImageData {
13
- type: 'image' | 'svg';
14
- src?: string;
15
- content?: string;
16
- width?: string;
17
- height?: string;
18
- }
19
-
20
- /**
21
- * Graphic associate data extracted from graphicAssociateInteraction elements
22
- */
23
- export interface GraphicAssociateData {
24
- imageData: ImageData | null;
25
- associableHotspots: Array<{
26
- identifier: string;
27
- label: string;
28
- shape: string;
29
- coords: string;
30
- matchMax: number;
31
- matchMin?: number;
32
- matchGroup?: string[];
33
- classes?: string[];
34
- }>;
35
- maxAssociations: number;
36
- minAssociations: number;
37
- prompt: string | null;
38
- }
39
-
40
- /**
41
- * Standard QTI graphic associate interaction extractor
42
- * Handles graphicAssociateInteraction elements (creating associations between hotspots)
43
- */
44
- export const standardGraphicAssociateExtractor: ElementExtractor<GraphicAssociateData> = {
45
- id: 'qti:graphic-associate-interaction',
46
- name: 'QTI Standard Graphic Associate Interaction',
47
- priority: 10,
48
- elementTypes: ['graphicAssociateInteraction'],
49
- description: 'Extracts standard QTI graphicAssociateInteraction (associate items on image)',
50
-
51
- canHandle(element, _context) {
52
- // All graphicAssociateInteraction elements are standard
53
- return element.rawTagName === 'graphicAssociateInteraction';
54
- },
55
-
56
- extract(element, context) {
57
- const { utils } = context;
58
-
59
- // Extract image data from object element
60
- const objectElements = utils.getChildrenByTag(element, 'object');
61
- let imageData: ImageData | null = null;
62
-
63
- if (objectElements.length > 0) {
64
- const objectElement = objectElements[0];
65
- const type = utils.getAttribute(objectElement, 'type', '');
66
- const data = utils.getAttribute(objectElement, 'data', '');
67
- const width = utils.getAttribute(objectElement, 'width', '500');
68
- const height = utils.getAttribute(objectElement, 'height', '300');
69
-
70
- if (type.startsWith('image/svg')) {
71
- // Extract inline SVG content - get full content including <svg> tag
72
- const content = utils.getHtmlContent(objectElement);
73
- imageData = {
74
- type: 'svg',
75
- content,
76
- width,
77
- height,
78
- };
79
- } else {
80
- // External image reference
81
- imageData = {
82
- type: 'image',
83
- src: data,
84
- width,
85
- height,
86
- };
87
- }
88
- }
89
-
90
- // Extract associableHotspot children
91
- const hotspotElements = utils.getChildrenByTag(element, 'associableHotspot');
92
- const associableHotspots = hotspotElements.map((hotspot) => {
93
- const classes = utils.getClasses(hotspot);
94
- const identifier = utils.getAttribute(hotspot, 'identifier', '');
95
- const shape = utils.getAttribute(hotspot, 'shape', 'rect');
96
- const coords = utils.getAttribute(hotspot, 'coords', '0,0,50,50');
97
- const matchMax = utils.getNumberAttribute(hotspot, 'matchMax', 1);
98
- const matchMin = utils.getNumberAttribute(hotspot, 'matchMin', 0);
99
- const matchGroupRaw = utils.getAttribute(hotspot, 'matchGroup', '');
100
- const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
101
-
102
- // Get text content as label, use identifier as fallback
103
- const textContent = utils.getTextContent(hotspot).trim();
104
- const label = textContent || identifier;
105
-
106
- return {
107
- identifier,
108
- label,
109
- shape,
110
- coords,
111
- matchMax,
112
- ...(matchMin > 0 ? { matchMin } : {}),
113
- ...(matchGroup.length > 0 ? { matchGroup } : {}),
114
- ...(classes.length > 0 ? { classes } : {}),
115
- };
116
- });
117
-
118
- // Extract attributes with proper defaults
119
- const maxAssociations = utils.getNumberAttribute(element, 'maxAssociations', 1);
120
- const minAssociations = utils.getNumberAttribute(element, 'minAssociations', 0);
121
-
122
- // Extract prompt (optional)
123
- const promptElements = utils.getChildrenByTag(element, 'prompt');
124
- const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
125
-
126
- return {
127
- imageData,
128
- associableHotspots,
129
- maxAssociations,
130
- minAssociations,
131
- prompt,
132
- };
133
- },
134
-
135
- validate(data) {
136
- const errors: string[] = [];
137
- const warnings: string[] = [];
138
-
139
- // Validate image data
140
- if (!data.imageData) {
141
- warnings.push('graphicAssociateInteraction has no image data');
142
- } else if (data.imageData.type === 'image' && !data.imageData.src) {
143
- errors.push('graphicAssociateInteraction must have an image URL');
144
- } else if (data.imageData.type === 'svg' && !data.imageData.content) {
145
- errors.push('graphicAssociateInteraction must have SVG content');
146
- }
147
-
148
- // Validate hotspots exist
149
- if (!data.associableHotspots || data.associableHotspots.length < 2) {
150
- errors.push('graphicAssociateInteraction must have at least 2 hotspots');
151
- }
152
-
153
- // Validate hotspot identifiers and coords
154
- if (data.associableHotspots && data.associableHotspots.length > 0) {
155
- const identifiers = new Set<string>();
156
- for (const hotspot of data.associableHotspots) {
157
- if (!hotspot.identifier) {
158
- errors.push('All hotspots must have an identifier');
159
- } else if (identifiers.has(hotspot.identifier)) {
160
- errors.push(`Duplicate hotspot identifier: ${hotspot.identifier}`);
161
- } else {
162
- identifiers.add(hotspot.identifier);
163
- }
164
-
165
- if (!hotspot.coords) {
166
- errors.push(`Hotspot ${hotspot.identifier} must have coords`);
167
- }
168
-
169
- // Validate matchMax
170
- if (hotspot.matchMax < 0) {
171
- errors.push(`matchMax must be non-negative for hotspot ${hotspot.identifier}`);
172
- }
173
- }
174
- }
175
-
176
- // Validate maxAssociations
177
- if (data.maxAssociations < 0) {
178
- errors.push('maxAssociations must be non-negative');
179
- }
180
-
181
- // Validate minAssociations
182
- if (data.minAssociations < 0) {
183
- errors.push('minAssociations must be non-negative');
184
- }
185
-
186
- return {
187
- valid: errors.length === 0,
188
- errors: errors.length > 0 ? errors : undefined,
189
- warnings: warnings.length > 0 ? warnings : undefined,
190
- };
191
- },
192
- };
1
+ export * from '../../interactions/graphic-associate/extractor.js';
@@ -1,257 +1 @@
1
- /**
2
- * Standard QTI graphicGapMatchInteraction extractor
3
- *
4
- * Extracts data from graphicGapMatchInteraction elements (drag text/images into gaps on image)
5
- */
6
-
7
- import type { ElementExtractor } from '../types.js';
8
-
9
- /**
10
- * Image data for graphic gap match interaction
11
- */
12
- export interface ImageData {
13
- type: 'image' | 'svg';
14
- src?: string;
15
- content?: string;
16
- width?: number;
17
- height?: number;
18
- }
19
-
20
- /**
21
- * Graphic gap match data extracted from graphicGapMatchInteraction elements
22
- */
23
- export interface GraphicGapMatchData {
24
- imageData: ImageData | null;
25
- maxAssociations: number;
26
- gapTexts: Array<{
27
- identifier: string;
28
- text: string;
29
- matchMax: number;
30
- matchMin?: number;
31
- matchGroup?: string[];
32
- classes?: string[];
33
- }>;
34
- gapImages: Array<{
35
- identifier: string;
36
- src: string;
37
- alt: string;
38
- matchMax: number;
39
- matchGroup?: string[];
40
- width?: number;
41
- height?: number;
42
- }>;
43
- hotspots: Array<{ identifier: string; shape: string; coords: string; matchMax: number }>;
44
- prompt: string | null;
45
- }
46
-
47
- /**
48
- * Standard QTI graphic gap match interaction extractor
49
- * Handles graphicGapMatchInteraction elements (drag text/images into gaps on an image)
50
- */
51
- export const standardGraphicGapMatchExtractor: ElementExtractor<GraphicGapMatchData> = {
52
- id: 'qti:graphic-gap-match-interaction',
53
- name: 'QTI Standard Graphic Gap Match Interaction',
54
- priority: 10,
55
- elementTypes: ['graphicGapMatchInteraction'],
56
- description: 'Extracts standard QTI graphicGapMatchInteraction (drag text/images into gaps)',
57
-
58
- canHandle(element, _context) {
59
- // All graphicGapMatchInteraction elements are standard
60
- return element.rawTagName === 'graphicGapMatchInteraction';
61
- },
62
-
63
- extract(element, context) {
64
- const { utils } = context;
65
-
66
- // Extract image data from object element
67
- const objectElements = utils.getChildrenByTag(element, 'object');
68
- let imageData: ImageData | null = null;
69
-
70
- if (objectElements.length > 0) {
71
- const objectElement = objectElements[0];
72
- const type = utils.getAttribute(objectElement, 'type', '');
73
- const data = utils.getAttribute(objectElement, 'data', '');
74
- const width = utils.getNumberAttribute(objectElement, 'width', 0);
75
- const height = utils.getNumberAttribute(objectElement, 'height', 0);
76
-
77
- if (type.startsWith('image/svg')) {
78
- // Inline SVG: <object type="image/svg+xml"><svg>...</svg></object>
79
- // External SVG: <object type="image/svg+xml" data="path/to/file.svg"/>
80
- // The <object> may contain alt text (not SVG markup) — only treat as inline if content has <svg.
81
- const content = utils.getHtmlContent(objectElement);
82
- const hasSvgMarkup = /<svg[\s>]/i.test(content);
83
- if (hasSvgMarkup) {
84
- imageData = {
85
- type: 'svg',
86
- content,
87
- ...(width > 0 ? { width } : {}),
88
- ...(height > 0 ? { height } : {}),
89
- };
90
- } else {
91
- // External SVG file reference — render via <img src>
92
- imageData = {
93
- type: 'image',
94
- src: data,
95
- ...(width > 0 ? { width } : {}),
96
- ...(height > 0 ? { height } : {}),
97
- };
98
- }
99
- } else {
100
- // External image reference
101
- imageData = {
102
- type: 'image',
103
- src: data,
104
- ...(width > 0 ? { width } : {}),
105
- ...(height > 0 ? { height } : {}),
106
- };
107
- }
108
- }
109
-
110
- // Extract interaction-level attributes
111
- const maxAssociations = utils.getNumberAttribute(element, 'maxAssociations', 0);
112
-
113
- // Extract gapText children (draggable text labels)
114
- const gapTextElements = utils.getChildrenByTag(element, 'gapText');
115
- const gapTexts = gapTextElements.map((gapText) => {
116
- const classes = utils.getClasses(gapText);
117
- const matchMax = utils.getNumberAttribute(gapText, 'matchMax', 1);
118
- const matchMin = utils.getNumberAttribute(gapText, 'matchMin', 0);
119
- const matchGroupRaw = utils.getAttribute(gapText, 'matchGroup', '');
120
- const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
121
- const text = utils.getHtmlContent(gapText);
122
-
123
- return {
124
- identifier: utils.getAttribute(gapText, 'identifier', ''),
125
- text,
126
- matchMax,
127
- ...(matchMin > 0 ? { matchMin } : {}),
128
- ...(matchGroup.length > 0 ? { matchGroup } : {}),
129
- ...(classes.length > 0 ? { classes } : {}),
130
- };
131
- });
132
-
133
- // Extract gapImg children (draggable image labels)
134
- const gapImgElements = utils.getChildrenByTag(element, 'gapImg');
135
- const gapImages = gapImgElements.map((gapImg) => {
136
- const matchMax = utils.getNumberAttribute(gapImg, 'matchMax', 1);
137
- const matchGroupRaw = utils.getAttribute(gapImg, 'matchGroup', '');
138
- const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
139
- const objectChildren = utils.getChildrenByTag(gapImg, 'object');
140
- let src = '';
141
- let alt = '';
142
- let width: number | undefined;
143
- let height: number | undefined;
144
- if (objectChildren.length > 0) {
145
- const obj = objectChildren[0];
146
- src = utils.getAttribute(obj, 'data', '');
147
- alt = utils.getTextContent(obj);
148
- const w = utils.getNumberAttribute(obj, 'width', 0);
149
- const h = utils.getNumberAttribute(obj, 'height', 0);
150
- if (w > 0) width = w;
151
- if (h > 0) height = h;
152
- }
153
- return {
154
- identifier: utils.getAttribute(gapImg, 'identifier', ''),
155
- src,
156
- alt,
157
- matchMax,
158
- ...(matchGroup.length > 0 ? { matchGroup } : {}),
159
- ...(width !== undefined ? { width } : {}),
160
- ...(height !== undefined ? { height } : {}),
161
- };
162
- });
163
-
164
- // Extract associableHotspot elements (gap targets)
165
- const hotspotElements = utils.getChildrenByTag(element, 'associableHotspot');
166
- const hotspots = hotspotElements.map((hotspot) => ({
167
- identifier: utils.getAttribute(hotspot, 'identifier', ''),
168
- shape: utils.getAttribute(hotspot, 'shape', 'rect'),
169
- coords: utils.getAttribute(hotspot, 'coords', ''),
170
- matchMax: utils.getNumberAttribute(hotspot, 'matchMax', 1),
171
- }));
172
-
173
- // Extract prompt (optional)
174
- const promptElements = utils.getChildrenByTag(element, 'prompt');
175
- const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
176
-
177
- const interactionClasses = utils.getClasses(element);
178
- const choicesContainerWidth = utils.getAttribute(element, 'data-choices-container-width', '') || null;
179
- const maxSelectionsMessage = utils.getAttribute(element, 'data-max-selections-message', '') || null;
180
- const minSelectionsMessage = utils.getAttribute(element, 'data-min-selections-message', '') || null;
181
-
182
- return {
183
- imageData,
184
- maxAssociations,
185
- gapTexts,
186
- gapImages,
187
- hotspots,
188
- prompt,
189
- ...(interactionClasses.length > 0 ? { interactionClasses } : {}),
190
- ...(choicesContainerWidth ? { choicesContainerWidth } : {}),
191
- ...(maxSelectionsMessage ? { maxSelectionsMessage } : {}),
192
- ...(minSelectionsMessage ? { minSelectionsMessage } : {}),
193
- };
194
- },
195
-
196
- validate(data) {
197
- const errors: string[] = [];
198
- const warnings: string[] = [];
199
-
200
- // Validate image data (optional but recommended)
201
- if (!data.imageData) {
202
- warnings.push('graphicGapMatchInteraction has no background image');
203
- } else if (data.imageData.type === 'image' && !data.imageData.src) {
204
- errors.push('graphicGapMatchInteraction must have an image URL');
205
- } else if (data.imageData.type === 'svg' && !data.imageData.content) {
206
- errors.push('graphicGapMatchInteraction must have SVG content');
207
- }
208
-
209
- // Validate that at least one draggable choice type is present
210
- if ((!data.gapTexts || data.gapTexts.length === 0) && (!data.gapImages || data.gapImages.length === 0)) {
211
- errors.push('graphicGapMatchInteraction must have at least one gapText or gapImg');
212
- }
213
-
214
- // Validate hotspots exist
215
- if (!data.hotspots || data.hotspots.length === 0) {
216
- errors.push('graphicGapMatchInteraction must have at least one hotspot');
217
- }
218
-
219
- // Validate gapText identifiers
220
- if (data.gapTexts) {
221
- const identifiers = new Set<string>();
222
- for (const gapText of data.gapTexts) {
223
- if (!gapText.identifier) {
224
- errors.push('All gapTexts must have an identifier');
225
- } else if (identifiers.has(gapText.identifier)) {
226
- errors.push(`Duplicate gapText identifier: ${gapText.identifier}`);
227
- } else {
228
- identifiers.add(gapText.identifier);
229
- }
230
- }
231
- }
232
-
233
- // Validate hotspot identifiers
234
- if (data.hotspots) {
235
- const identifiers = new Set<string>();
236
- for (const hotspot of data.hotspots) {
237
- if (!hotspot.identifier) {
238
- errors.push('All hotspots must have an identifier');
239
- } else if (identifiers.has(hotspot.identifier)) {
240
- errors.push(`Duplicate hotspot identifier: ${hotspot.identifier}`);
241
- } else {
242
- identifiers.add(hotspot.identifier);
243
- }
244
-
245
- if (!hotspot.coords) {
246
- errors.push(`Hotspot ${hotspot.identifier} must have coords`);
247
- }
248
- }
249
- }
250
-
251
- return {
252
- valid: errors.length === 0,
253
- errors: errors.length > 0 ? errors : undefined,
254
- warnings: warnings.length > 0 ? warnings : undefined,
255
- };
256
- },
257
- };
1
+ export * from '../../interactions/graphic-gap-match/extractor.js';
@@ -1,162 +1 @@
1
- /**
2
- * Standard QTI graphicOrderInteraction extractor
3
- *
4
- * Extracts data from graphicOrderInteraction elements (order items on image)
5
- */
6
-
7
- import type { ElementExtractor } from '../types.js';
8
-
9
- /**
10
- * Image data for graphic order interaction
11
- */
12
- export interface ImageData {
13
- type: 'image' | 'svg';
14
- src?: string;
15
- content?: string;
16
- width?: string;
17
- height?: string;
18
- }
19
-
20
- /**
21
- * Graphic order data extracted from graphicOrderInteraction elements
22
- */
23
- export interface GraphicOrderData {
24
- imageData: ImageData | null;
25
- hotspotChoices: Array<{
26
- identifier: string;
27
- label: string;
28
- shape: string;
29
- coords: string;
30
- fixed?: boolean;
31
- classes?: string[];
32
- }>;
33
- prompt: string | null;
34
- }
35
-
36
- /**
37
- * Standard QTI graphic order interaction extractor
38
- * Handles graphicOrderInteraction elements (ordering hotspots on an image)
39
- */
40
- export const standardGraphicOrderExtractor: ElementExtractor<GraphicOrderData> = {
41
- id: 'qti:graphic-order-interaction',
42
- name: 'QTI Standard Graphic Order Interaction',
43
- priority: 10,
44
- elementTypes: ['graphicOrderInteraction'],
45
- description: 'Extracts standard QTI graphicOrderInteraction (order items on image)',
46
-
47
- canHandle(element, _context) {
48
- // All graphicOrderInteraction elements are standard
49
- return element.rawTagName === 'graphicOrderInteraction';
50
- },
51
-
52
- extract(element, context) {
53
- const { utils } = context;
54
-
55
- // Extract image data from object element
56
- const objectElements = utils.getChildrenByTag(element, 'object');
57
- let imageData: ImageData | null = null;
58
-
59
- if (objectElements.length > 0) {
60
- const objectElement = objectElements[0];
61
- const type = utils.getAttribute(objectElement, 'type', '');
62
- const data = utils.getAttribute(objectElement, 'data', '');
63
- const width = utils.getAttribute(objectElement, 'width', '500');
64
- const height = utils.getAttribute(objectElement, 'height', '300');
65
-
66
- if (type.startsWith('image/svg')) {
67
- // Extract inline SVG content - get full content including <svg> tag
68
- const content = utils.getHtmlContent(objectElement);
69
- imageData = {
70
- type: 'svg',
71
- content,
72
- width,
73
- height,
74
- };
75
- } else {
76
- // External image reference
77
- imageData = {
78
- type: 'image',
79
- src: data,
80
- width,
81
- height,
82
- };
83
- }
84
- }
85
-
86
- // Extract hotspotChoice children
87
- const hotspotElements = utils.getChildrenByTag(element, 'hotspotChoice');
88
- const hotspotChoices = hotspotElements.map((hotspot) => {
89
- const classes = utils.getClasses(hotspot);
90
- const identifier = utils.getAttribute(hotspot, 'identifier', '');
91
- const shape = utils.getAttribute(hotspot, 'shape', 'rect');
92
- const coords = utils.getAttribute(hotspot, 'coords', '0,0,50,50');
93
- const fixed = utils.getBooleanAttribute(hotspot, 'fixed');
94
-
95
- // Get text content as label, use identifier as fallback
96
- const textContent = utils.getTextContent(hotspot).trim();
97
- const label = textContent || identifier;
98
-
99
- return {
100
- identifier,
101
- label,
102
- shape,
103
- coords,
104
- ...(fixed ? { fixed } : {}),
105
- ...(classes.length > 0 ? { classes } : {}),
106
- };
107
- });
108
-
109
- // Extract prompt (optional)
110
- const promptElements = utils.getChildrenByTag(element, 'prompt');
111
- const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
112
-
113
- return {
114
- imageData,
115
- hotspotChoices,
116
- prompt,
117
- };
118
- },
119
-
120
- validate(data) {
121
- const errors: string[] = [];
122
- const warnings: string[] = [];
123
-
124
- // Validate image data
125
- if (!data.imageData) {
126
- warnings.push('graphicOrderInteraction has no image data');
127
- } else if (data.imageData.type === 'image' && !data.imageData.src) {
128
- errors.push('graphicOrderInteraction must have an image URL');
129
- } else if (data.imageData.type === 'svg' && !data.imageData.content) {
130
- errors.push('graphicOrderInteraction must have SVG content');
131
- }
132
-
133
- // Validate hotspot choices exist
134
- if (!data.hotspotChoices || data.hotspotChoices.length < 2) {
135
- errors.push('graphicOrderInteraction must have at least 2 hotspots');
136
- }
137
-
138
- // Validate hotspot choice identifiers and coords
139
- if (data.hotspotChoices) {
140
- const identifiers = new Set<string>();
141
- for (const hotspot of data.hotspotChoices) {
142
- if (!hotspot.identifier) {
143
- errors.push('All hotspot choices must have an identifier');
144
- } else if (identifiers.has(hotspot.identifier)) {
145
- errors.push(`Duplicate hotspot identifier: ${hotspot.identifier}`);
146
- } else {
147
- identifiers.add(hotspot.identifier);
148
- }
149
-
150
- if (!hotspot.coords) {
151
- errors.push(`Hotspot ${hotspot.identifier} must have coords`);
152
- }
153
- }
154
- }
155
-
156
- return {
157
- valid: errors.length === 0,
158
- errors: errors.length > 0 ? errors : undefined,
159
- warnings: warnings.length > 0 ? warnings : undefined,
160
- };
161
- },
162
- };
1
+ export * from '../../interactions/graphic-order/extractor.js';