@pie-qti/item-player 0.1.18 → 0.1.20

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 (259) hide show
  1. package/README.md +137 -427
  2. package/dist/catalog/applyGlossaryTriggers.d.ts +2 -1
  3. package/dist/catalog/applyGlossaryTriggers.js +4 -2
  4. package/dist/catalog/applyGlossaryTriggers.js.map +1 -1
  5. package/dist/components/utils/stimulusRender.d.ts +1 -2
  6. package/dist/components/utils/stimulusRender.js +2 -5
  7. package/dist/components/utils/stimulusRender.js.map +1 -1
  8. package/dist/core/AssessmentItemDefinition.d.ts +69 -0
  9. package/dist/core/AssessmentItemDefinition.js +149 -0
  10. package/dist/core/AssessmentItemDefinition.js.map +1 -0
  11. package/dist/core/ComponentRegistry.d.ts +11 -5
  12. package/dist/core/ComponentRegistry.js +44 -17
  13. package/dist/core/ComponentRegistry.js.map +1 -1
  14. package/dist/core/ItemSession.d.ts +58 -0
  15. package/dist/core/ItemSession.js +286 -0
  16. package/dist/core/ItemSession.js.map +1 -0
  17. package/dist/core/Player.d.ts +9 -8
  18. package/dist/core/Player.js +182 -163
  19. package/dist/core/Player.js.map +1 -1
  20. package/dist/core/sanitizer.js +33 -10
  21. package/dist/core/sanitizer.js.map +1 -1
  22. package/dist/document/AssessmentItemDocument.d.ts +32 -10
  23. package/dist/document/AssessmentItemDocument.js +80 -23
  24. package/dist/document/AssessmentItemDocument.js.map +1 -1
  25. package/dist/{element-class-C8OTgYHE.js → element-class-CILJ4Ls7.js} +3583 -2779
  26. package/dist/element-class-CILJ4Ls7.js.map +1 -0
  27. package/dist/element-class.d.ts +17 -13
  28. package/dist/element-class.js +1 -1
  29. package/dist/element.js +1 -1
  30. package/dist/extraction/ExtractionRegistry.d.ts +34 -11
  31. package/dist/extraction/ExtractionRegistry.js +122 -19
  32. package/dist/extraction/ExtractionRegistry.js.map +1 -1
  33. package/dist/extraction/createContext.d.ts +5 -6
  34. package/dist/extraction/createContext.js +2 -2
  35. package/dist/extraction/createContext.js.map +1 -1
  36. package/dist/extraction/deliveryTypes.d.ts +26 -0
  37. package/dist/extraction/deliveryTypes.js +7 -0
  38. package/dist/extraction/deliveryTypes.js.map +1 -0
  39. package/dist/extraction/index.d.ts +3 -3
  40. package/dist/extraction/index.js +1 -2
  41. package/dist/extraction/index.js.map +1 -1
  42. package/dist/extraction/interactionExtractionPipeline.d.ts +4 -4
  43. package/dist/extraction/interactionExtractionPipeline.js +27 -10
  44. package/dist/extraction/interactionExtractionPipeline.js.map +1 -1
  45. package/dist/extraction/interactionSecurity.d.ts +11 -2
  46. package/dist/extraction/interactionSecurity.js +105 -40
  47. package/dist/extraction/interactionSecurity.js.map +1 -1
  48. package/dist/extraction/types.d.ts +44 -7
  49. package/dist/extraction/types.js.map +1 -1
  50. package/dist/extraction/utils.js +4 -16
  51. package/dist/extraction/utils.js.map +1 -1
  52. package/dist/index.d.ts +9 -8
  53. package/dist/index.js +5 -7
  54. package/dist/index.js.map +1 -1
  55. package/dist/interactions/associate/extractor.js +1 -1
  56. package/dist/interactions/associate/extractor.js.map +1 -1
  57. package/dist/interactions/drawing/extractor.js +5 -4
  58. package/dist/interactions/drawing/extractor.js.map +1 -1
  59. package/dist/interactions/end-attempt/extractor.js +2 -2
  60. package/dist/interactions/end-attempt/extractor.js.map +1 -1
  61. package/dist/interactions/gap-match/extractor.js +4 -3
  62. package/dist/interactions/gap-match/extractor.js.map +1 -1
  63. package/dist/interactions/graphic-associate/extractor.js +5 -4
  64. package/dist/interactions/graphic-associate/extractor.js.map +1 -1
  65. package/dist/interactions/graphic-gap-match/extractor.js +20 -17
  66. package/dist/interactions/graphic-gap-match/extractor.js.map +1 -1
  67. package/dist/interactions/graphic-order/extractor.js +5 -4
  68. package/dist/interactions/graphic-order/extractor.js.map +1 -1
  69. package/dist/interactions/hotspot/extractor.js +11 -10
  70. package/dist/interactions/hotspot/extractor.js.map +1 -1
  71. package/dist/interactions/inline/render-plan.d.ts +3 -5
  72. package/dist/interactions/inline/render-plan.js.map +1 -1
  73. package/dist/interactions/media/extractor.js +2 -2
  74. package/dist/interactions/media/extractor.js.map +1 -1
  75. package/dist/interactions/modules.d.ts +11 -91
  76. package/dist/interactions/modules.js +185 -45
  77. package/dist/interactions/modules.js.map +1 -1
  78. package/dist/interactions/portable-custom/extractor.d.ts +1 -1
  79. package/dist/interactions/portable-custom/extractor.js +1 -1
  80. package/dist/interactions/portable-custom/extractor.js.map +1 -1
  81. package/dist/interactions/position-object/extractor.js +3 -2
  82. package/dist/interactions/position-object/extractor.js.map +1 -1
  83. package/dist/interactions/select-point/extractor.js +7 -6
  84. package/dist/interactions/select-point/extractor.js.map +1 -1
  85. package/dist/interactions/shared/types.d.ts +59 -70
  86. package/dist/interactions/shared/types.js.map +1 -1
  87. package/dist/interactions/slider/extractor.js +2 -2
  88. package/dist/interactions/slider/extractor.js.map +1 -1
  89. package/dist/interactions/upload/extractor.js +2 -2
  90. package/dist/interactions/upload/extractor.js.map +1 -1
  91. package/dist/pci/types.d.ts +2 -3
  92. package/dist/pci/types.js.map +1 -1
  93. package/dist/presentation/itemPresentationPlan.d.ts +71 -38
  94. package/dist/presentation/itemPresentationPlan.js +78 -34
  95. package/dist/presentation/itemPresentationPlan.js.map +1 -1
  96. package/dist/security/index.d.ts +1 -1
  97. package/dist/security/index.js +1 -1
  98. package/dist/security/index.js.map +1 -1
  99. package/dist/security/styleValues.d.ts +20 -0
  100. package/dist/security/styleValues.js +49 -0
  101. package/dist/security/styleValues.js.map +1 -0
  102. package/dist/server.d.ts +188 -9
  103. package/dist/server.js +32 -7
  104. package/dist/server.js.map +1 -1
  105. package/dist/types/index.d.ts +1 -110
  106. package/dist/types/index.js.map +1 -1
  107. package/dist/web-components/QTIInteractionBase.d.ts +2 -2
  108. package/dist/web-components/QTIInteractionBase.js.map +1 -1
  109. package/dist/web-components/QTIInteractionElement.d.ts +3 -3
  110. package/dist/web-components/QTIInteractionElement.js.map +1 -1
  111. package/package.json +11 -11
  112. package/dist/core/Plugin.d.ts +0 -104
  113. package/dist/core/Plugin.js +0 -8
  114. package/dist/core/Plugin.js.map +0 -1
  115. package/dist/core/PluginManager.d.ts +0 -55
  116. package/dist/core/PluginManager.js +0 -148
  117. package/dist/core/PluginManager.js.map +0 -1
  118. package/dist/element-class-C8OTgYHE.js.map +0 -1
  119. package/dist/interactions/associate/index.d.ts +0 -2
  120. package/dist/interactions/associate/index.js +0 -2
  121. package/dist/interactions/associate/index.js.map +0 -1
  122. package/dist/interactions/associate/types.d.ts +0 -1
  123. package/dist/interactions/associate/types.js +0 -2
  124. package/dist/interactions/associate/types.js.map +0 -1
  125. package/dist/interactions/choice/index.d.ts +0 -2
  126. package/dist/interactions/choice/index.js +0 -2
  127. package/dist/interactions/choice/index.js.map +0 -1
  128. package/dist/interactions/choice/types.d.ts +0 -1
  129. package/dist/interactions/choice/types.js +0 -2
  130. package/dist/interactions/choice/types.js.map +0 -1
  131. package/dist/interactions/custom/index.d.ts +0 -2
  132. package/dist/interactions/custom/index.js +0 -2
  133. package/dist/interactions/custom/index.js.map +0 -1
  134. package/dist/interactions/custom/types.d.ts +0 -1
  135. package/dist/interactions/custom/types.js +0 -2
  136. package/dist/interactions/custom/types.js.map +0 -1
  137. package/dist/interactions/drawing/index.d.ts +0 -2
  138. package/dist/interactions/drawing/index.js +0 -2
  139. package/dist/interactions/drawing/index.js.map +0 -1
  140. package/dist/interactions/drawing/types.d.ts +0 -1
  141. package/dist/interactions/drawing/types.js +0 -2
  142. package/dist/interactions/drawing/types.js.map +0 -1
  143. package/dist/interactions/end-attempt/index.d.ts +0 -2
  144. package/dist/interactions/end-attempt/index.js +0 -2
  145. package/dist/interactions/end-attempt/index.js.map +0 -1
  146. package/dist/interactions/end-attempt/types.d.ts +0 -1
  147. package/dist/interactions/end-attempt/types.js +0 -2
  148. package/dist/interactions/end-attempt/types.js.map +0 -1
  149. package/dist/interactions/extended-text/index.d.ts +0 -3
  150. package/dist/interactions/extended-text/index.js +0 -3
  151. package/dist/interactions/extended-text/index.js.map +0 -1
  152. package/dist/interactions/extended-text/types.d.ts +0 -1
  153. package/dist/interactions/extended-text/types.js +0 -2
  154. package/dist/interactions/extended-text/types.js.map +0 -1
  155. package/dist/interactions/gap-match/index.d.ts +0 -2
  156. package/dist/interactions/gap-match/index.js +0 -2
  157. package/dist/interactions/gap-match/index.js.map +0 -1
  158. package/dist/interactions/gap-match/types.d.ts +0 -1
  159. package/dist/interactions/gap-match/types.js +0 -2
  160. package/dist/interactions/gap-match/types.js.map +0 -1
  161. package/dist/interactions/graphic-associate/index.d.ts +0 -2
  162. package/dist/interactions/graphic-associate/index.js +0 -2
  163. package/dist/interactions/graphic-associate/index.js.map +0 -1
  164. package/dist/interactions/graphic-associate/types.d.ts +0 -1
  165. package/dist/interactions/graphic-associate/types.js +0 -2
  166. package/dist/interactions/graphic-associate/types.js.map +0 -1
  167. package/dist/interactions/graphic-gap-match/index.d.ts +0 -2
  168. package/dist/interactions/graphic-gap-match/index.js +0 -2
  169. package/dist/interactions/graphic-gap-match/index.js.map +0 -1
  170. package/dist/interactions/graphic-gap-match/types.d.ts +0 -1
  171. package/dist/interactions/graphic-gap-match/types.js +0 -2
  172. package/dist/interactions/graphic-gap-match/types.js.map +0 -1
  173. package/dist/interactions/graphic-order/index.d.ts +0 -2
  174. package/dist/interactions/graphic-order/index.js +0 -2
  175. package/dist/interactions/graphic-order/index.js.map +0 -1
  176. package/dist/interactions/graphic-order/types.d.ts +0 -1
  177. package/dist/interactions/graphic-order/types.js +0 -2
  178. package/dist/interactions/graphic-order/types.js.map +0 -1
  179. package/dist/interactions/hotspot/index.d.ts +0 -2
  180. package/dist/interactions/hotspot/index.js +0 -2
  181. package/dist/interactions/hotspot/index.js.map +0 -1
  182. package/dist/interactions/hotspot/types.d.ts +0 -1
  183. package/dist/interactions/hotspot/types.js +0 -2
  184. package/dist/interactions/hotspot/types.js.map +0 -1
  185. package/dist/interactions/hottext/index.d.ts +0 -2
  186. package/dist/interactions/hottext/index.js +0 -2
  187. package/dist/interactions/hottext/index.js.map +0 -1
  188. package/dist/interactions/hottext/types.d.ts +0 -1
  189. package/dist/interactions/hottext/types.js +0 -2
  190. package/dist/interactions/hottext/types.js.map +0 -1
  191. package/dist/interactions/index.d.ts +0 -32
  192. package/dist/interactions/index.js +0 -31
  193. package/dist/interactions/index.js.map +0 -1
  194. package/dist/interactions/inline/index.d.ts +0 -1
  195. package/dist/interactions/inline/index.js +0 -2
  196. package/dist/interactions/inline/index.js.map +0 -1
  197. package/dist/interactions/inline-choice/index.d.ts +0 -2
  198. package/dist/interactions/inline-choice/index.js +0 -2
  199. package/dist/interactions/inline-choice/index.js.map +0 -1
  200. package/dist/interactions/inline-choice/types.d.ts +0 -1
  201. package/dist/interactions/inline-choice/types.js +0 -2
  202. package/dist/interactions/inline-choice/types.js.map +0 -1
  203. package/dist/interactions/match/index.d.ts +0 -2
  204. package/dist/interactions/match/index.js +0 -2
  205. package/dist/interactions/match/index.js.map +0 -1
  206. package/dist/interactions/match/types.d.ts +0 -1
  207. package/dist/interactions/match/types.js +0 -2
  208. package/dist/interactions/match/types.js.map +0 -1
  209. package/dist/interactions/media/index.d.ts +0 -2
  210. package/dist/interactions/media/index.js +0 -2
  211. package/dist/interactions/media/index.js.map +0 -1
  212. package/dist/interactions/media/types.d.ts +0 -1
  213. package/dist/interactions/media/types.js +0 -2
  214. package/dist/interactions/media/types.js.map +0 -1
  215. package/dist/interactions/order/index.d.ts +0 -2
  216. package/dist/interactions/order/index.js +0 -2
  217. package/dist/interactions/order/index.js.map +0 -1
  218. package/dist/interactions/order/types.d.ts +0 -1
  219. package/dist/interactions/order/types.js +0 -2
  220. package/dist/interactions/order/types.js.map +0 -1
  221. package/dist/interactions/portable-custom/index.d.ts +0 -2
  222. package/dist/interactions/portable-custom/index.js +0 -2
  223. package/dist/interactions/portable-custom/index.js.map +0 -1
  224. package/dist/interactions/portable-custom/types.d.ts +0 -1
  225. package/dist/interactions/portable-custom/types.js +0 -2
  226. package/dist/interactions/portable-custom/types.js.map +0 -1
  227. package/dist/interactions/position-object/index.d.ts +0 -2
  228. package/dist/interactions/position-object/index.js +0 -2
  229. package/dist/interactions/position-object/index.js.map +0 -1
  230. package/dist/interactions/position-object/types.d.ts +0 -1
  231. package/dist/interactions/position-object/types.js +0 -2
  232. package/dist/interactions/position-object/types.js.map +0 -1
  233. package/dist/interactions/select-point/index.d.ts +0 -2
  234. package/dist/interactions/select-point/index.js +0 -2
  235. package/dist/interactions/select-point/index.js.map +0 -1
  236. package/dist/interactions/select-point/types.d.ts +0 -1
  237. package/dist/interactions/select-point/types.js +0 -2
  238. package/dist/interactions/select-point/types.js.map +0 -1
  239. package/dist/interactions/shared/index.d.ts +0 -1
  240. package/dist/interactions/shared/index.js +0 -2
  241. package/dist/interactions/shared/index.js.map +0 -1
  242. package/dist/interactions/slider/index.d.ts +0 -2
  243. package/dist/interactions/slider/index.js +0 -2
  244. package/dist/interactions/slider/index.js.map +0 -1
  245. package/dist/interactions/slider/types.d.ts +0 -1
  246. package/dist/interactions/slider/types.js +0 -2
  247. package/dist/interactions/slider/types.js.map +0 -1
  248. package/dist/interactions/text-entry/index.d.ts +0 -2
  249. package/dist/interactions/text-entry/index.js +0 -2
  250. package/dist/interactions/text-entry/index.js.map +0 -1
  251. package/dist/interactions/text-entry/types.d.ts +0 -1
  252. package/dist/interactions/text-entry/types.js +0 -2
  253. package/dist/interactions/text-entry/types.js.map +0 -1
  254. package/dist/interactions/upload/index.d.ts +0 -2
  255. package/dist/interactions/upload/index.js +0 -2
  256. package/dist/interactions/upload/index.js.map +0 -1
  257. package/dist/interactions/upload/types.d.ts +0 -1
  258. package/dist/interactions/upload/types.js +0 -2
  259. package/dist/interactions/upload/types.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-qti/item-player",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Modern QTI player supporting QTI 2.2 and 3.0 - Client-side with optional backend hooks",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -8,7 +8,7 @@
8
8
  "scripts": {
9
9
  "build": "vite build && tsc",
10
10
  "dev": "tsc --watch",
11
- "test": "bun test",
11
+ "test": "bun test && tsc -p ./tsconfig.server-types.test.json",
12
12
  "typecheck": "tsc --noEmit",
13
13
  "check": "svelte-check --tsconfig ./tsconfig.svelte.json",
14
14
  "lint": "biome check .",
@@ -27,22 +27,22 @@
27
27
  ],
28
28
  "license": "MIT",
29
29
  "dependencies": {
30
- "@pie-qti/i18n": "0.1.18",
31
- "@pie-qti/ims-cp-core": "0.1.18",
32
- "@pie-qti/qti-common": "0.1.18",
33
- "@pie-qti/qti-processing": "0.1.18",
30
+ "@pie-qti/i18n": "0.1.20",
31
+ "@pie-qti/ims-cp-core": "0.1.20",
32
+ "@pie-qti/qti-common": "0.1.20",
33
+ "@pie-qti/qti-processing": "0.1.20",
34
34
  "mathlive": "^0.110.0",
35
35
  "node-html-parser": "^9.0.1"
36
36
  },
37
37
  "devDependencies": {
38
- "@biomejs/biome": "^2.5.6",
39
- "@sveltejs/vite-plugin-svelte": "^7.0.0",
40
- "@types/node": "^25.0.3",
38
+ "@biomejs/biome": "^2.5.7",
39
+ "@sveltejs/vite-plugin-svelte": "^7.3.0",
40
+ "@types/node": "^26.2.0",
41
41
  "svelte": "^5.56.8",
42
- "svelte-check": "^4.3.5",
42
+ "svelte-check": "^4.7.5",
43
43
  "typescript": "^5.9.3",
44
44
  "vite": "^8.0.10",
45
- "vite-plugin-dts": "^4.5.4"
45
+ "vite-plugin-dts": "^5.0.3"
46
46
  },
47
47
  "exports": {
48
48
  ".": {
@@ -1,104 +0,0 @@
1
- /**
2
- * Plugin System for QTI 2.2 Item Player
3
- *
4
- * Provides extensible plugin architecture for custom extractors
5
- * and interaction rendering.
6
- */
7
- import type { ExtractionRegistry } from '../extraction/ExtractionRegistry.js';
8
- import type { PlayerConfig, QTIRole } from '../types/index.js';
9
- import type { ComponentRegistry } from './ComponentRegistry.js';
10
- import type { Player } from './Player.js';
11
- /**
12
- * QTI element type (from node-html-parser or browser DOM)
13
- */
14
- export type QTIElement = any;
15
- /**
16
- * QTI Plugin interface
17
- *
18
- * Plugins can register custom extractors and web components to handle vendor-specific QTI extensions.
19
- *
20
- * @example
21
- * ```typescript
22
- * const myPlugin: QTIPlugin = {
23
- * name: '@vendor/my-qti-plugin',
24
- * version: '1.0.0',
25
- * description: 'Custom QTI extensions',
26
- *
27
- * registerExtractors(registry: ExtractionRegistry) {
28
- * // Register custom element extractors
29
- * registry.register(myCustomExtractor);
30
- * },
31
- *
32
- * registerComponents(registry: ComponentRegistry) {
33
- * // Register custom web components
34
- * registry.register('choiceInteraction', {
35
- * name: 'my-choice',
36
- * priority: 100,
37
- * canHandle: (data) => data.interactionClasses?.includes('my-custom'),
38
- * tagName: 'my-custom-choice'
39
- * });
40
- * }
41
- * };
42
- * ```
43
- */
44
- export interface QTIPlugin {
45
- /** Unique plugin identifier */
46
- name: string;
47
- /** Semantic version */
48
- version: string;
49
- /** Optional plugin description */
50
- description?: string;
51
- /** Dependencies on other plugins (by name) */
52
- dependencies?: string[];
53
- /** Lifecycle hooks */
54
- lifecycle?: PluginLifecycle;
55
- /** Register custom extractors with the extraction registry */
56
- registerExtractors?(registry: ExtractionRegistry): void;
57
- /** Register custom web components with the component registry */
58
- registerComponents?(registry: ComponentRegistry): void;
59
- }
60
- /**
61
- * Plugin lifecycle hooks
62
- */
63
- export interface PluginLifecycle {
64
- /** Called when plugin is registered */
65
- onRegister?(context: PluginContext): void | Promise<void>;
66
- /** Called before item rendering starts */
67
- onBeforeRender?(context: RenderContext): void | Promise<void>;
68
- /** Called after item rendering completes */
69
- onAfterRender?(context: RenderContext): void | Promise<void>;
70
- /** Called when plugin is unregistered */
71
- onUnregister?(): void | Promise<void>;
72
- }
73
- /**
74
- * Context provided to plugins during registration
75
- *
76
- * Note: Player reference is NOT available during registration to avoid circular dependencies.
77
- * Use RenderContext for lifecycle hooks that need Player access.
78
- */
79
- export interface PluginContext {
80
- /** Extraction registry for custom extractors */
81
- extractionRegistry: ExtractionRegistry;
82
- /** Component registry for custom web components */
83
- componentRegistry: ComponentRegistry;
84
- /** Item document (if loaded) - can be browser Document or node-html-parser HTMLElement */
85
- dom?: QTIElement;
86
- /** Player configuration */
87
- config: PlayerConfig;
88
- }
89
- /**
90
- * Context provided during rendering lifecycle hooks
91
- * Extends PluginContext with Player instance access
92
- */
93
- export interface RenderContext extends PluginContext {
94
- /** Player instance (available during render hooks) */
95
- player: Player;
96
- /**
97
- * Rendering context (minimal and stable).
98
- * Note: rendering is via web components; this config is primarily for lifecycle hooks.
99
- */
100
- config: {
101
- role: QTIRole;
102
- options?: Record<string, any>;
103
- };
104
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Plugin System for QTI 2.2 Item Player
3
- *
4
- * Provides extensible plugin architecture for custom extractors
5
- * and interaction rendering.
6
- */
7
- export {};
8
- //# sourceMappingURL=Plugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Plugin.js","sourceRoot":"","sources":["../../src/core/Plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG","sourcesContent":["/**\n * Plugin System for QTI 2.2 Item Player\n *\n * Provides extensible plugin architecture for custom extractors\n * and interaction rendering.\n */\n\nimport type { ExtractionRegistry } from '../extraction/ExtractionRegistry.js';\nimport type { PlayerConfig, QTIRole } from '../types/index.js';\nimport type { ComponentRegistry } from './ComponentRegistry.js';\nimport type { Player } from './Player.js';\n\n/**\n * QTI element type (from node-html-parser or browser DOM)\n */\nexport type QTIElement = any;\n\n/**\n * QTI Plugin interface\n *\n * Plugins can register custom extractors and web components to handle vendor-specific QTI extensions.\n *\n * @example\n * ```typescript\n * const myPlugin: QTIPlugin = {\n * name: '@vendor/my-qti-plugin',\n * version: '1.0.0',\n * description: 'Custom QTI extensions',\n *\n * registerExtractors(registry: ExtractionRegistry) {\n * // Register custom element extractors\n * registry.register(myCustomExtractor);\n * },\n *\n * registerComponents(registry: ComponentRegistry) {\n * // Register custom web components\n * registry.register('choiceInteraction', {\n * name: 'my-choice',\n * priority: 100,\n * canHandle: (data) => data.interactionClasses?.includes('my-custom'),\n * tagName: 'my-custom-choice'\n * });\n * }\n * };\n * ```\n */\nexport interface QTIPlugin {\n\t/** Unique plugin identifier */\n\tname: string;\n\n\t/** Semantic version */\n\tversion: string;\n\n\t/** Optional plugin description */\n\tdescription?: string;\n\n\t/** Dependencies on other plugins (by name) */\n\tdependencies?: string[];\n\n\t/** Lifecycle hooks */\n\tlifecycle?: PluginLifecycle;\n\n\t/** Register custom extractors with the extraction registry */\n\tregisterExtractors?(registry: ExtractionRegistry): void;\n\n\t/** Register custom web components with the component registry */\n\tregisterComponents?(registry: ComponentRegistry): void;\n}\n\n/**\n * Plugin lifecycle hooks\n */\nexport interface PluginLifecycle {\n\t/** Called when plugin is registered */\n\tonRegister?(context: PluginContext): void | Promise<void>;\n\n\t/** Called before item rendering starts */\n\tonBeforeRender?(context: RenderContext): void | Promise<void>;\n\n\t/** Called after item rendering completes */\n\tonAfterRender?(context: RenderContext): void | Promise<void>;\n\n\t/** Called when plugin is unregistered */\n\tonUnregister?(): void | Promise<void>;\n}\n\n/**\n * Context provided to plugins during registration\n *\n * Note: Player reference is NOT available during registration to avoid circular dependencies.\n * Use RenderContext for lifecycle hooks that need Player access.\n */\nexport interface PluginContext {\n\t/** Extraction registry for custom extractors */\n\textractionRegistry: ExtractionRegistry;\n\n\t/** Component registry for custom web components */\n\tcomponentRegistry: ComponentRegistry;\n\n\t/** Item document (if loaded) - can be browser Document or node-html-parser HTMLElement */\n\tdom?: QTIElement;\n\n\t/** Player configuration */\n\tconfig: PlayerConfig;\n}\n\n/**\n * Context provided during rendering lifecycle hooks\n * Extends PluginContext with Player instance access\n */\nexport interface RenderContext extends PluginContext {\n\t/** Player instance (available during render hooks) */\n\tplayer: Player;\n\n\t/**\n\t * Rendering context (minimal and stable).\n\t * Note: rendering is via web components; this config is primarily for lifecycle hooks.\n\t */\n\tconfig: {\n\t\trole: QTIRole;\n\t\toptions?: Record<string, any>;\n\t};\n}\n"]}
@@ -1,55 +0,0 @@
1
- /**
2
- * Plugin Manager
3
- *
4
- * Manages plugin registration, dependency resolution, and lifecycle.
5
- */
6
- import type { PluginContext, QTIPlugin, RenderContext } from './Plugin.js';
7
- export declare class PluginManager {
8
- private plugins;
9
- private initialized;
10
- /**
11
- * Register a plugin
12
- * @throws Error if plugin is invalid or dependencies are missing
13
- */
14
- register(plugin: QTIPlugin, context: PluginContext): Promise<void>;
15
- /**
16
- * Unregister a plugin
17
- */
18
- unregister(pluginName: string): Promise<void>;
19
- /**
20
- * Get all registered plugins
21
- */
22
- getAll(): QTIPlugin[];
23
- /**
24
- * Get plugin by name
25
- */
26
- get(name: string): QTIPlugin | undefined;
27
- /**
28
- * Check if plugin is registered
29
- */
30
- has(name: string): boolean;
31
- /**
32
- * Check if plugin is initialized
33
- */
34
- isInitialized(name: string): boolean;
35
- /**
36
- * Call onBeforeRender hooks for all plugins
37
- */
38
- callBeforeRenderHooks(context: RenderContext): Promise<void>;
39
- /**
40
- * Call onAfterRender hooks for all plugins
41
- */
42
- callAfterRenderHooks(context: RenderContext): Promise<void>;
43
- /**
44
- * Validate plugin structure
45
- */
46
- private validatePlugin;
47
- /**
48
- * Check if plugin dependencies are satisfied
49
- */
50
- private checkDependencies;
51
- /**
52
- * Clear all plugins
53
- */
54
- clear(): Promise<void>;
55
- }
@@ -1,148 +0,0 @@
1
- /**
2
- * Plugin Manager
3
- *
4
- * Manages plugin registration, dependency resolution, and lifecycle.
5
- */
6
- export class PluginManager {
7
- constructor() {
8
- this.plugins = new Map();
9
- this.initialized = new Set();
10
- }
11
- /**
12
- * Register a plugin
13
- * @throws Error if plugin is invalid or dependencies are missing
14
- */
15
- async register(plugin, context) {
16
- // Validate plugin
17
- this.validatePlugin(plugin);
18
- // Check if already registered
19
- if (this.plugins.has(plugin.name)) {
20
- throw new Error(`Plugin '${plugin.name}' is already registered`);
21
- }
22
- // Check dependencies
23
- await this.checkDependencies(plugin);
24
- // Store plugin
25
- this.plugins.set(plugin.name, plugin);
26
- // Call lifecycle hook
27
- try {
28
- await plugin.lifecycle?.onRegister?.(context);
29
- this.initialized.add(plugin.name);
30
- }
31
- catch (error) {
32
- // Rollback on error
33
- this.plugins.delete(plugin.name);
34
- throw new Error(`Failed to initialize plugin '${plugin.name}': ${error instanceof Error ? error.message : String(error)}`);
35
- }
36
- }
37
- /**
38
- * Unregister a plugin
39
- */
40
- async unregister(pluginName) {
41
- const plugin = this.plugins.get(pluginName);
42
- if (!plugin)
43
- return;
44
- try {
45
- // Call lifecycle hook
46
- await plugin.lifecycle?.onUnregister?.();
47
- }
48
- finally {
49
- // Remove plugin even if hook fails
50
- this.plugins.delete(pluginName);
51
- this.initialized.delete(pluginName);
52
- }
53
- }
54
- /**
55
- * Get all registered plugins
56
- */
57
- getAll() {
58
- return Array.from(this.plugins.values());
59
- }
60
- /**
61
- * Get plugin by name
62
- */
63
- get(name) {
64
- return this.plugins.get(name);
65
- }
66
- /**
67
- * Check if plugin is registered
68
- */
69
- has(name) {
70
- return this.plugins.has(name);
71
- }
72
- /**
73
- * Check if plugin is initialized
74
- */
75
- isInitialized(name) {
76
- return this.initialized.has(name);
77
- }
78
- // Legacy getRendererRegistrations() method removed
79
- // Plugins now register components via ComponentRegistry instead
80
- /**
81
- * Call onBeforeRender hooks for all plugins
82
- */
83
- async callBeforeRenderHooks(context) {
84
- for (const plugin of this.plugins.values()) {
85
- try {
86
- await plugin.lifecycle?.onBeforeRender?.(context);
87
- }
88
- catch (error) {
89
- console.error(`Plugin '${plugin.name}' onBeforeRender hook failed:`, error);
90
- }
91
- }
92
- }
93
- /**
94
- * Call onAfterRender hooks for all plugins
95
- */
96
- async callAfterRenderHooks(context) {
97
- for (const plugin of this.plugins.values()) {
98
- try {
99
- await plugin.lifecycle?.onAfterRender?.(context);
100
- }
101
- catch (error) {
102
- console.error(`Plugin '${plugin.name}' onAfterRender hook failed:`, error);
103
- }
104
- }
105
- }
106
- /**
107
- * Validate plugin structure
108
- */
109
- validatePlugin(plugin) {
110
- if (!plugin.name || typeof plugin.name !== 'string') {
111
- throw new Error('Plugin must have a valid name');
112
- }
113
- if (!plugin.version || typeof plugin.version !== 'string') {
114
- throw new Error(`Plugin '${plugin.name}' must have a valid version`);
115
- }
116
- // Validate semantic version format (basic check)
117
- if (!/^\d+\.\d+\.\d+/.test(plugin.version)) {
118
- throw new Error(`Plugin '${plugin.name}' has invalid version format: ${plugin.version}`);
119
- }
120
- }
121
- /**
122
- * Check if plugin dependencies are satisfied
123
- */
124
- async checkDependencies(plugin) {
125
- if (!plugin.dependencies || plugin.dependencies.length === 0) {
126
- return;
127
- }
128
- const missing = [];
129
- for (const dep of plugin.dependencies) {
130
- if (!this.plugins.has(dep)) {
131
- missing.push(dep);
132
- }
133
- }
134
- if (missing.length > 0) {
135
- throw new Error(`Plugin '${plugin.name}' has missing dependencies: ${missing.join(', ')}`);
136
- }
137
- }
138
- /**
139
- * Clear all plugins
140
- */
141
- async clear() {
142
- const plugins = Array.from(this.plugins.keys());
143
- for (const pluginName of plugins) {
144
- await this.unregister(pluginName);
145
- }
146
- }
147
- }
148
- //# sourceMappingURL=PluginManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PluginManager.js","sourceRoot":"","sources":["../../src/core/PluginManager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,MAAM,OAAO,aAAa;IAA1B;QACS,YAAO,GAAG,IAAI,GAAG,EAAqB,CAAC;QACvC,gBAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IAuKzC,CAAC;IArKA;;;OAGG;IACH,KAAK,CAAC,QAAQ,CAAC,MAAiB,EAAE,OAAsB;QACvD,kBAAkB;QAClB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAE5B,8BAA8B;QAC9B,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,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AM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAEhD,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE,CAAC;YAClC,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACnC,CAAC;IACF,CAAC;CACD","sourcesContent":["/**\n * Plugin Manager\n *\n * Manages plugin registration, dependency resolution, and lifecycle.\n */\n\nimport type {\n\tPluginContext,\n\tQTIPlugin,\n\tRenderContext\n} from './Plugin.js';\n\nexport class PluginManager {\n\tprivate plugins = new Map<string, QTIPlugin>();\n\tprivate initialized = new Set<string>();\n\n\t/**\n\t * Register a plugin\n\t * @throws Error if plugin is invalid or dependencies are missing\n\t */\n\tasync register(plugin: QTIPlugin, context: PluginContext): Promise<void> {\n\t\t// Validate plugin\n\t\tthis.validatePlugin(plugin);\n\n\t\t// Check if already registered\n\t\tif (this.plugins.has(plugin.name)) {\n\t\t\tthrow new Error(`Plugin '${plugin.name}' is already registered`);\n\t\t}\n\n\t\t// Check dependencies\n\t\tawait this.checkDependencies(plugin);\n\n\t\t// Store plugin\n\t\tthis.plugins.set(plugin.name, plugin);\n\n\t\t// Call lifecycle hook\n\t\ttry {\n\t\t\tawait plugin.lifecycle?.onRegister?.(context);\n\t\t\tthis.initialized.add(plugin.name);\n\t\t} catch (error) {\n\t\t\t// Rollback on error\n\t\t\tthis.plugins.delete(plugin.name);\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to initialize plugin '${plugin.name}': ${error instanceof Error ? error.message : String(error)}`\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Unregister a plugin\n\t */\n\tasync unregister(pluginName: string): Promise<void> {\n\t\tconst plugin = this.plugins.get(pluginName);\n\t\tif (!plugin) return;\n\n\t\ttry {\n\t\t\t// Call lifecycle hook\n\t\t\tawait plugin.lifecycle?.onUnregister?.();\n\t\t} finally {\n\t\t\t// Remove plugin even if hook fails\n\t\t\tthis.plugins.delete(pluginName);\n\t\t\tthis.initialized.delete(pluginName);\n\t\t}\n\t}\n\n\t/**\n\t * Get all registered plugins\n\t */\n\tgetAll(): QTIPlugin[] {\n\t\treturn Array.from(this.plugins.values());\n\t}\n\n\t/**\n\t * Get plugin by name\n\t */\n\tget(name: string): QTIPlugin | undefined {\n\t\treturn this.plugins.get(name);\n\t}\n\n\t/**\n\t * Check if plugin is registered\n\t */\n\thas(name: string): boolean {\n\t\treturn this.plugins.has(name);\n\t}\n\n\t/**\n\t * Check if plugin is initialized\n\t */\n\tisInitialized(name: string): boolean {\n\t\treturn this.initialized.has(name);\n\t}\n\n\t// Legacy getRendererRegistrations() method removed\n\t// Plugins now register components via ComponentRegistry instead\n\n\t/**\n\t * Call onBeforeRender hooks for all plugins\n\t */\n\tasync callBeforeRenderHooks(context: RenderContext): Promise<void> {\n\t\tfor (const plugin of this.plugins.values()) {\n\t\t\ttry {\n\t\t\t\tawait plugin.lifecycle?.onBeforeRender?.(context);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`Plugin '${plugin.name}' onBeforeRender hook failed:`,\n\t\t\t\t\terror\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Call onAfterRender hooks for all plugins\n\t */\n\tasync callAfterRenderHooks(context: RenderContext): Promise<void> {\n\t\tfor (const plugin of this.plugins.values()) {\n\t\t\ttry {\n\t\t\t\tawait plugin.lifecycle?.onAfterRender?.(context);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`Plugin '${plugin.name}' onAfterRender hook failed:`,\n\t\t\t\t\terror\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Validate plugin structure\n\t */\n\tprivate validatePlugin(plugin: QTIPlugin): void {\n\t\tif (!plugin.name || typeof plugin.name !== 'string') {\n\t\t\tthrow new Error('Plugin must have a valid name');\n\t\t}\n\n\t\tif (!plugin.version || typeof plugin.version !== 'string') {\n\t\t\tthrow new Error(`Plugin '${plugin.name}' must have a valid version`);\n\t\t}\n\n\t\t// Validate semantic version format (basic check)\n\t\tif (!/^\\d+\\.\\d+\\.\\d+/.test(plugin.version)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Plugin '${plugin.name}' has invalid version format: ${plugin.version}`\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Check if plugin dependencies are satisfied\n\t */\n\tprivate async checkDependencies(plugin: QTIPlugin): Promise<void> {\n\t\tif (!plugin.dependencies || plugin.dependencies.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst missing: string[] = [];\n\n\t\tfor (const dep of plugin.dependencies) {\n\t\t\tif (!this.plugins.has(dep)) {\n\t\t\t\tmissing.push(dep);\n\t\t\t}\n\t\t}\n\n\t\tif (missing.length > 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Plugin '${plugin.name}' has missing dependencies: ${missing.join(', ')}`\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Clear all plugins\n\t */\n\tasync clear(): Promise<void> {\n\t\tconst plugins = Array.from(this.plugins.keys());\n\n\t\tfor (const pluginName of plugins) {\n\t\t\tawait this.unregister(pluginName);\n\t\t}\n\t}\n}\n"]}