@pie-qti/item-player 0.1.15 → 0.1.17

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 (88) hide show
  1. package/README.md +18 -6
  2. package/dist/core/ComponentRegistry.js +1 -0
  3. package/dist/core/ComponentRegistry.js.map +1 -1
  4. package/dist/core/Player.d.ts +4 -0
  5. package/dist/core/Player.js +296 -89
  6. package/dist/core/Player.js.map +1 -1
  7. package/dist/core/declarations.js +11 -4
  8. package/dist/core/declarations.js.map +1 -1
  9. package/dist/core/sanitizer.js +119 -1
  10. package/dist/core/sanitizer.js.map +1 -1
  11. package/dist/core/shuffle.d.ts +42 -0
  12. package/dist/core/shuffle.js +83 -0
  13. package/dist/core/shuffle.js.map +1 -0
  14. package/dist/core/urlPolicy.js +34 -23
  15. package/dist/core/urlPolicy.js.map +1 -1
  16. package/dist/element-class-BLaOCHDu.js +6926 -0
  17. package/dist/element-class-BLaOCHDu.js.map +1 -0
  18. package/dist/element-class.d.ts +73 -0
  19. package/dist/element-class.js +2 -0
  20. package/dist/element.d.ts +6 -40
  21. package/dist/element.js +4 -6299
  22. package/dist/element.js.map +1 -1
  23. package/dist/extraction/ExtractionRegistry.js +1 -1
  24. package/dist/extraction/ExtractionRegistry.js.map +1 -1
  25. package/dist/extraction/createContext.d.ts +1 -1
  26. package/dist/extraction/createContext.js +5 -1
  27. package/dist/extraction/createContext.js.map +1 -1
  28. package/dist/extraction/interactionExtractionPipeline.d.ts +6 -1
  29. package/dist/extraction/interactionExtractionPipeline.js +6 -3
  30. package/dist/extraction/interactionExtractionPipeline.js.map +1 -1
  31. package/dist/extraction/types.d.ts +10 -0
  32. package/dist/extraction/types.js.map +1 -1
  33. package/dist/index.d.ts +2 -2
  34. package/dist/index.js +1 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/interactions/associate/extractor.js +2 -1
  37. package/dist/interactions/associate/extractor.js.map +1 -1
  38. package/dist/interactions/choice/extractor.js +2 -1
  39. package/dist/interactions/choice/extractor.js.map +1 -1
  40. package/dist/interactions/custom/extractor.js +22 -2
  41. package/dist/interactions/custom/extractor.js.map +1 -1
  42. package/dist/interactions/extended-text/extractor.d.ts +6 -0
  43. package/dist/interactions/extended-text/extractor.js +40 -6
  44. package/dist/interactions/extended-text/extractor.js.map +1 -1
  45. package/dist/interactions/extended-text/index.d.ts +1 -0
  46. package/dist/interactions/extended-text/index.js +1 -0
  47. package/dist/interactions/extended-text/index.js.map +1 -1
  48. package/dist/interactions/extended-text/response.d.ts +31 -0
  49. package/dist/interactions/extended-text/response.js +193 -0
  50. package/dist/interactions/extended-text/response.js.map +1 -0
  51. package/dist/interactions/gap-match/extractor.js +8 -7
  52. package/dist/interactions/gap-match/extractor.js.map +1 -1
  53. package/dist/interactions/inline-choice/extractor.js +2 -1
  54. package/dist/interactions/inline-choice/extractor.js.map +1 -1
  55. package/dist/interactions/match/extractor.js +3 -2
  56. package/dist/interactions/match/extractor.js.map +1 -1
  57. package/dist/interactions/modules.d.ts +4 -0
  58. package/dist/interactions/modules.js +2 -0
  59. package/dist/interactions/modules.js.map +1 -1
  60. package/dist/interactions/order/extractor.js +2 -1
  61. package/dist/interactions/order/extractor.js.map +1 -1
  62. package/dist/interactions/portable-custom/extractor.d.ts +3 -2
  63. package/dist/interactions/portable-custom/extractor.js +66 -25
  64. package/dist/interactions/portable-custom/extractor.js.map +1 -1
  65. package/dist/interactions/portable-custom/index.d.ts +1 -1
  66. package/dist/interactions/portable-custom/index.js.map +1 -1
  67. package/dist/interactions/portable-custom/types.d.ts +1 -1
  68. package/dist/interactions/portable-custom/types.js.map +1 -1
  69. package/dist/interactions/position-object/extractor.d.ts +5 -35
  70. package/dist/interactions/position-object/extractor.js +58 -153
  71. package/dist/interactions/position-object/extractor.js.map +1 -1
  72. package/dist/interactions/shared/types.d.ts +15 -1
  73. package/dist/interactions/shared/types.js.map +1 -1
  74. package/dist/pci/PciHost.d.ts +14 -9
  75. package/dist/pci/PciHost.js +89 -22
  76. package/dist/pci/PciHost.js.map +1 -1
  77. package/dist/pci/index.d.ts +3 -0
  78. package/dist/pci/index.js +3 -0
  79. package/dist/pci/index.js.map +1 -0
  80. package/dist/pci/types.d.ts +72 -0
  81. package/dist/pci/types.js +12 -0
  82. package/dist/pci/types.js.map +1 -1
  83. package/dist/presentation/itemPresentationPlan.d.ts +2 -0
  84. package/dist/presentation/itemPresentationPlan.js +6 -0
  85. package/dist/presentation/itemPresentationPlan.js.map +1 -1
  86. package/dist/types/index.d.ts +26 -5
  87. package/dist/types/index.js.map +1 -1
  88. package/package.json +19 -11
package/README.md CHANGED
@@ -4,16 +4,22 @@ A modern assessment item player for QTI 2.2 and QTI 3.0 content, with role/view-
4
4
 
5
5
  ## Features
6
6
 
7
- - ✅ **21 QTI Interaction Types Supported** - QTI standard interaction set across 2.2/3.0 naming variants
7
+ - **21 standard interaction extractors** across QTI 2.2/3.0 naming variants; known rendering and conformance gaps are tracked in `docs/SPEC-GAPS-PLAN.md`
8
8
  - ✅ **QTI Role/View Actors** - candidate, scorer, author, tutor, proctor, testConstructor
9
9
  - ✅ **Adaptive Items** - Multi-attempt workflow with progressive feedback
10
10
  - ✅ **Full Keyboard Accessibility** (follows WCAG 2.2 Level AA guidelines)
11
11
  - ✅ **Client-Side Response Processing** with 45/45 QTI operators
12
12
  - ✅ **Framework-Agnostic Core** with a **Web Component interaction layer** (default implementations authored in Svelte)
13
13
  - ✅ **TypeScript** with full type definitions
14
- - ✅ **Minimal Dependencies** (node-html-parser for XML parsing)
14
+ - **No Svelte dependency for consumers of the framework-agnostic core**
15
15
  - ✅ **Iframe mode (reference)** - Optional host helper + postMessage protocol for iframe-isolated deployments
16
16
 
17
+ > **Security boundary (2026-07-13):** QTI-derived same-DOM sinks, including gap-match prompts and
18
+ > section TTS projections, use the shared sanitizer and have executable-markup regression coverage.
19
+ > The item custom element enables parsing limits by default. Sanitization is not a JavaScript
20
+ > sandbox: for content that is not trusted to run in the host origin, prefer a cross-origin
21
+ > sandboxed iframe. See `docs/prds/architecture/security.md` in the repository.
22
+
17
23
  ## Installation
18
24
 
19
25
  ```bash
@@ -30,7 +36,12 @@ npm install @pie-qti/item-player
30
36
 
31
37
  ### Web Component Host Integration
32
38
 
33
- For browser applications, the public rendering boundary is the custom element:
39
+ For browser applications, the public rendering boundary is the custom element. The default
40
+ interaction implementations are a separate package, so install both packages:
41
+
42
+ ```bash
43
+ npm install @pie-qti/item-player @pie-qti/default-components
44
+ ```
34
45
 
35
46
  ```typescript
36
47
  import '@pie-qti/default-components/plugins';
@@ -41,9 +52,10 @@ import '@pie-qti/item-player/element';
41
52
  <pie-qti-item-player item-xml="<assessmentItem ...></assessmentItem>" role="author"></pie-qti-item-player>
42
53
  ```
43
54
 
44
- The package does not require hosts to import Svelte components. Internal Svelte
45
- components are compiled into the custom element bundle and are not part of the
46
- public package contract.
55
+ The package does not require hosts to import Svelte components or install Svelte. Internal Svelte
56
+ components are compiled into the custom element bundle. Importing
57
+ `@pie-qti/default-components/plugins` is currently required; `@pie-qti/default-components` is not a
58
+ dependency of this package.
47
59
 
48
60
  ### Core Player (Framework-Agnostic)
49
61
 
@@ -16,6 +16,7 @@ const DEFAULT_COMPONENT_TAGS_BY_TYPE = {
16
16
  hottextInteraction: { name: 'default-hottext', tagName: 'pie-qti-hottext' },
17
17
  mediaInteraction: { name: 'default-media', tagName: 'pie-qti-media' },
18
18
  customInteraction: { name: 'default-custom', tagName: 'pie-qti-custom' },
19
+ portableCustomInteraction: { name: 'default-portable-custom', tagName: 'pie-qti-portable-custom' },
19
20
  endAttemptInteraction: { name: 'default-end-attempt', tagName: 'pie-qti-end-attempt' },
20
21
  positionObjectInteraction: { name: 'default-position-object', tagName: 'pie-qti-position-object' },
21
22
  graphicGapMatchInteraction: { name: 'default-graphic-gap-match', tagName: 'pie-qti-graphic-gap-match' },
@@ -1 +1 @@
1
- {"version":3,"file":"ComponentRegistry.js","sourceRoot":"","sources":["../../src/core/ComponentRegistry.ts"],"names":[],"mappings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C,GAAG,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QACxD,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;IACrC,CAAC;CACD;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACtC,MAAM,QAAQ,GAAG,IAAI,iBAAiB,EAAE,CAAC;IACzC,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IACvC,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAAC,QAA2B;IACvE,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,8BAA8B,CAAC,EAAE,CAAC;QAChF,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE;YACvB,GAAG,SAAS;YACZ,WAAW,EAAE,iCAAiC,IAAI,EAAE;YACpD,QAAQ,EAAE,CAAC,GAAG;SACd,CAAC,CAAC;IACJ,CAAC;AACF,CAAC","sourcesContent":["/**\n * Component Registry for Web Component-based Interaction Rendering\n *\n * Provides a pluggable system for registering web components to render\n * different QTI interaction types. Uses priority-based dispatch similar to the\n * ExtractionRegistry, but for framework-agnostic web components.\n */\n\nimport type { InteractionData } from '../interactions/index.js';\n\n/**\n * Configuration for registering a web component renderer\n */\nexport interface ComponentConfig<TData extends InteractionData = InteractionData> {\n\t/** Unique name for this renderer (e.g., 'rating-choice', 'standard-choice') */\n\tname: string;\n\n\t/**\n\t * Priority for renderer evaluation (higher = checked first)\n\t * - 100: Very specific custom renderers\n\t * - 50: Moderately specific custom renderers\n\t * - 10: Generic custom renderers\n\t * - 0: Default fallback renderers\n\t * Default: 0\n\t */\n\tpriority?: number;\n\n\t/** Optional description for debugging/error messages */\n\tdescription?: string;\n\n\t/**\n\t * Predicate to determine if this component can handle the interaction\n\t * Evaluated in priority order (highest first)\n\t * @returns true if this component should be used\n\t * Default: always true\n\t */\n\tcanHandle?: (data: TData) => boolean;\n\n\t/**\n\t * Web component tag name (must contain a hyphen per web component spec)\n\t * e.g., 'qti-choice-interaction', 'custom-rating-choice'\n\t */\n\ttagName: string;\n\n\t/**\n\t * Optional web component class constructor\n\t * If provided, the component will be automatically registered with customElements\n\t */\n\tcomponentClass?: CustomElementConstructor;\n\n\t/**\n\t * Whether to automatically register the component with customElements\n\t * Default: true if componentClass is provided\n\t */\n\tautoRegister?: boolean;\n}\n\n/**\n * Internal registered component with metadata\n */\ninterface RegisteredComponent<TData extends InteractionData = InteractionData> {\n\tconfig: ComponentConfig<TData> & {\n\t\tpriority: number;\n\t\tcanHandle: (data: TData) => boolean;\n\t};\n}\n\nconst DEFAULT_COMPONENT_TAGS_BY_TYPE = {\n\tchoiceInteraction: { name: 'default-choice', tagName: 'pie-qti-choice' },\n\tsliderInteraction: { name: 'default-slider', tagName: 'pie-qti-slider' },\n\torderInteraction: { name: 'default-order', tagName: 'pie-qti-order' },\n\tmatchInteraction: { name: 'default-match', tagName: 'pie-qti-match' },\n\tassociateInteraction: { name: 'default-associate', tagName: 'pie-qti-associate' },\n\tgapMatchInteraction: { name: 'default-gap-match', tagName: 'pie-qti-gap-match' },\n\thotspotInteraction: { name: 'default-hotspot', tagName: 'pie-qti-hotspot' },\n\thottextInteraction: { name: 'default-hottext', tagName: 'pie-qti-hottext' },\n\tmediaInteraction: { name: 'default-media', tagName: 'pie-qti-media' },\n\tcustomInteraction: { name: 'default-custom', tagName: 'pie-qti-custom' },\n\tendAttemptInteraction: { name: 'default-end-attempt', tagName: 'pie-qti-end-attempt' },\n\tpositionObjectInteraction: { name: 'default-position-object', tagName: 'pie-qti-position-object' },\n\tgraphicGapMatchInteraction: { name: 'default-graphic-gap-match', tagName: 'pie-qti-graphic-gap-match' },\n\tgraphicOrderInteraction: { name: 'default-graphic-order', tagName: 'pie-qti-graphic-order' },\n\tgraphicAssociateInteraction: { name: 'default-graphic-associate', tagName: 'pie-qti-graphic-associate' },\n\tselectPointInteraction: { name: 'default-select-point', tagName: 'pie-qti-select-point' },\n\textendedTextInteraction: { name: 'default-extended-text', tagName: 'pie-qti-extended-text' },\n\tuploadInteraction: { name: 'default-upload', tagName: 'pie-qti-upload' },\n\tdrawingInteraction: { name: 'default-drawing', tagName: 'pie-qti-drawing' },\n\tcatalogPopup: { name: 'default-catalog-popup', tagName: 'pie-qti-catalog-popup' },\n} satisfies Record<string, { name: string; tagName: string }>;\n\n/**\n * Registry for web components that render QTI interactions\n */\nexport class ComponentRegistry {\n\tprivate components = new Map<string, RegisteredComponent[]>();\n\tprivate definedElements = new Set<string>();\n\n\t/**\n\t * Register a web component for an interaction type with priority-based dispatch\n\t *\n\t * @param type - QTI interaction type (e.g., 'choiceInteraction', 'textEntryInteraction')\n\t * @param config - Component configuration with priority and canHandle predicate\n\t *\n\t * @example\n\t * // Custom rating choice component with high priority\n\t * registry.register('choiceInteraction', {\n\t * name: 'rating-choice',\n\t * priority: 100,\n\t * description: 'Star rating interactions',\n\t * canHandle: (data) => data.interactionClasses?.includes('rating-interaction'),\n\t * tagName: 'custom-rating-choice',\n\t * componentClass: RatingChoiceInteraction,\n\t * autoRegister: true\n\t * });\n\t *\n\t * // Default choice component\n\t * registry.register('choiceInteraction', {\n\t * name: 'standard-choice',\n\t * tagName: 'qti-choice-interaction'\n\t * });\n\t */\n\tregister<TData extends InteractionData>(\n\t\ttype: string,\n\t\tconfig: ComponentConfig<TData>\n\t): void {\n\t\t// Validate tag name\n\t\tif (!config.tagName.includes('-')) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid tag name '${config.tagName}'. ` +\n\t\t\t\t\t`Web component tag names must contain a hyphen.`\n\t\t\t);\n\t\t}\n\n\t\t// Auto-register custom element if requested\n\t\tif (config.componentClass && config.autoRegister !== false) {\n\t\t\tif (!this.definedElements.has(config.tagName)) {\n\t\t\t\tif (!customElements.get(config.tagName)) {\n\t\t\t\t\tcustomElements.define(config.tagName, config.componentClass);\n\t\t\t\t}\n\t\t\t\tthis.definedElements.add(config.tagName);\n\t\t\t}\n\t\t}\n\n\t\t// Get or create component array for this type\n\t\tlet components = this.components.get(type);\n\t\tif (!components) {\n\t\t\tcomponents = [];\n\t\t\tthis.components.set(type, components);\n\t\t}\n\n\t\t// Add normalized component and sort by priority (highest first)\n\t\tcomponents.push(this.createRegisteredComponent(config) as RegisteredComponent);\n\t\tcomponents.sort((a, b) => b.config.priority - a.config.priority);\n\t}\n\n\tprivate createRegisteredComponent<TData extends InteractionData>(\n\t\tconfig: ComponentConfig<TData>\n\t): RegisteredComponent<TData> {\n\t\treturn {\n\t\t\tconfig: {\n\t\t\t\t...config,\n\t\t\t\tpriority: config.priority ?? 0,\n\t\t\t\tcanHandle: config.canHandle ?? (() => true),\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Get a web component tag name for an interaction type\n\t * Evaluates canHandle predicates in priority order\n\t *\n\t * @param data - Interaction data\n\t * @returns Web component tag name (e.g., 'qti-choice-interaction')\n\t * @throws Error if no component matches\n\t */\n\tgetTagName<TData extends InteractionData>(data: TData): string {\n\t\tconst components = this.components.get(data.type);\n\n\t\tif (!components || components.length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`No component registered for '${data.type}' interaction. ` +\n\t\t\t\t\t`Available types: ${Array.from(this.components.keys()).join(', ')}`\n\t\t\t);\n\t\t}\n\n\t\t// Evaluate canHandle in priority order\n\t\tfor (const { config } of components) {\n\t\t\ttry {\n\t\t\t\tif (config.canHandle(data as any)) {\n\t\t\t\t\treturn config.tagName;\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\t// Log but continue to next component\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`canHandle() failed for '${config.name}' component:`,\n\t\t\t\t\terror\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// No component matched\n\t\tconst componentList = components\n\t\t\t.map((c) => {\n\t\t\t\tconst desc = c.config.description ? ` (${c.config.description})` : '';\n\t\t\t\treturn `${c.config.name}${desc}`;\n\t\t\t})\n\t\t\t.join(', ');\n\n\t\tthrow new Error(\n\t\t\t`No component available for '${data.type}' interaction.\\n` +\n\t\t\t\t`Registered components: ${componentList}.\\n` +\n\t\t\t\t`None of these components matched the current interaction.`\n\t\t);\n\t}\n\n\t/**\n\t * Get all registered interaction types\n\t * @returns Array of registered interaction type names\n\t */\n\tgetRegisteredTypes(): string[] {\n\t\treturn Array.from(this.components.keys());\n\t}\n\n\t/**\n\t * Check if a component is registered for a type\n\t */\n\thasComponent(type: string): boolean {\n\t\treturn this.components.has(type) && this.components.get(type)!.length > 0;\n\t}\n\n\t/**\n\t * Get the tag name for a registered type by name (no canHandle evaluation).\n\t * Useful for non-interaction components like catalogPopup where the type string\n\t * is known and there is no InteractionData object to pass.\n\t *\n\t * Returns the highest-priority registered tag name for the type, or null if\n\t * the type is not registered.\n\t */\n\tgetTagNameForType(type: string): string | null {\n\t\tconst components = this.components.get(type);\n\t\tif (!components || components.length === 0) return null;\n\t\treturn components[0].config.tagName;\n\t}\n}\n\n/**\n * Create a new component registry\n */\nexport function createComponentRegistry(): ComponentRegistry {\n\tconst registry = new ComponentRegistry();\n\tregisterDefaultComponentTags(registry);\n\treturn registry;\n}\n\n/**\n * Register the default QTI interaction tag names without importing their implementations.\n *\n * Hosts still choose the implementation bundle, typically by importing\n * `@pie-qti/default-components/plugins` in the browser. Keeping only tag metadata here lets\n * the item-player custom element remain the public rendering boundary without depending on\n * Svelte-authored default components.\n */\nexport function registerDefaultComponentTags(registry: ComponentRegistry): void {\n\tfor (const [type, component] of Object.entries(DEFAULT_COMPONENT_TAGS_BY_TYPE)) {\n\t\tregistry.register(type, {\n\t\t\t...component,\n\t\t\tdescription: `Default web component tag for ${type}`,\n\t\t\tpriority: -100,\n\t\t});\n\t}\n}\n\n/**\n * Plugin interface for registering web components\n */\nexport interface ComponentPlugin {\n\t/** Plugin name (e.g., '@renaissance/rating-choice') */\n\tname: string;\n\n\t/** Plugin version (semver) */\n\tversion: string;\n\n\t/** Plugin description */\n\tdescription: string;\n\n\t/**\n\t * Register web components with the registry\n\t * @param registry - ComponentRegistry instance\n\t */\n\tregister(registry: ComponentRegistry): void;\n}\n"]}
1
+ {"version":3,"file":"ComponentRegistry.js","sourceRoot":"","sources":["../../src/core/ComponentRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA6DH,MAAM,8BAA8B,GAAG;IACtC,iBAAiB,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,EAAE;IACxE,iBAAiB,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,EAAE;IACxE,gBAAgB,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,EAAE;IACrE,gBAAgB,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,EAAE;IACrE,oBAAoB,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,mBAAmB,EAAE;IACjF,mBAAmB,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,mBAAmB,EAAE;IAChF,kBAAkB,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,iBAAiB,EAAE;IAC3E,kBAAkB,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,iBAAiB,EAAE;IAC3E,gBAAgB,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,EAAE;IACrE,iBAAiB,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,EAAE;IACxE,yBAAyB,EAAE,EAAE,IAAI,EAAE,yBAAyB,EAAE,OAAO,EAAE,yBAAyB,EAAE;IAClG,qBAAqB,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,qBAAqB,EAAE;IACtF,yBAAy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E,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3E,CAAC;IAED;;;;;;;OAOG;IACH,iBAAiB,CAAC,IAAY;QAC7B,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QACxD,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;IACrC,CAAC;CACD;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACtC,MAAM,QAAQ,GAAG,IAAI,iBAAiB,EAAE,CAAC;IACzC,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IACvC,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAAC,QAA2B;IACvE,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,8BAA8B,CAAC,EAAE,CAAC;QAChF,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE;YACvB,GAAG,SAAS;YACZ,WAAW,EAAE,iCAAiC,IAAI,EAAE;YACpD,QAAQ,EAAE,CAAC,GAAG;SACd,CAAC,CAAC;IACJ,CAAC;AACF,CAAC","sourcesContent":["/**\n * Component Registry for Web Component-based Interaction Rendering\n *\n * Provides a pluggable system for registering web components to render\n * different QTI interaction types. Uses priority-based dispatch similar to the\n * ExtractionRegistry, but for framework-agnostic web components.\n */\n\nimport type { InteractionData } from '../interactions/index.js';\n\n/**\n * Configuration for registering a web component renderer\n */\nexport interface ComponentConfig<TData extends InteractionData = InteractionData> {\n\t/** Unique name for this renderer (e.g., 'rating-choice', 'standard-choice') */\n\tname: string;\n\n\t/**\n\t * Priority for renderer evaluation (higher = checked first)\n\t * - 100: Very specific custom renderers\n\t * - 50: Moderately specific custom renderers\n\t * - 10: Generic custom renderers\n\t * - 0: Default fallback renderers\n\t * Default: 0\n\t */\n\tpriority?: number;\n\n\t/** Optional description for debugging/error messages */\n\tdescription?: string;\n\n\t/**\n\t * Predicate to determine if this component can handle the interaction\n\t * Evaluated in priority order (highest first)\n\t * @returns true if this component should be used\n\t * Default: always true\n\t */\n\tcanHandle?: (data: TData) => boolean;\n\n\t/**\n\t * Web component tag name (must contain a hyphen per web component spec)\n\t * e.g., 'qti-choice-interaction', 'custom-rating-choice'\n\t */\n\ttagName: string;\n\n\t/**\n\t * Optional web component class constructor\n\t * If provided, the component will be automatically registered with customElements\n\t */\n\tcomponentClass?: CustomElementConstructor;\n\n\t/**\n\t * Whether to automatically register the component with customElements\n\t * Default: true if componentClass is provided\n\t */\n\tautoRegister?: boolean;\n}\n\n/**\n * Internal registered component with metadata\n */\ninterface RegisteredComponent<TData extends InteractionData = InteractionData> {\n\tconfig: ComponentConfig<TData> & {\n\t\tpriority: number;\n\t\tcanHandle: (data: TData) => boolean;\n\t};\n}\n\nconst DEFAULT_COMPONENT_TAGS_BY_TYPE = {\n\tchoiceInteraction: { name: 'default-choice', tagName: 'pie-qti-choice' },\n\tsliderInteraction: { name: 'default-slider', tagName: 'pie-qti-slider' },\n\torderInteraction: { name: 'default-order', tagName: 'pie-qti-order' },\n\tmatchInteraction: { name: 'default-match', tagName: 'pie-qti-match' },\n\tassociateInteraction: { name: 'default-associate', tagName: 'pie-qti-associate' },\n\tgapMatchInteraction: { name: 'default-gap-match', tagName: 'pie-qti-gap-match' },\n\thotspotInteraction: { name: 'default-hotspot', tagName: 'pie-qti-hotspot' },\n\thottextInteraction: { name: 'default-hottext', tagName: 'pie-qti-hottext' },\n\tmediaInteraction: { name: 'default-media', tagName: 'pie-qti-media' },\n\tcustomInteraction: { name: 'default-custom', tagName: 'pie-qti-custom' },\n\tportableCustomInteraction: { name: 'default-portable-custom', tagName: 'pie-qti-portable-custom' },\n\tendAttemptInteraction: { name: 'default-end-attempt', tagName: 'pie-qti-end-attempt' },\n\tpositionObjectInteraction: { name: 'default-position-object', tagName: 'pie-qti-position-object' },\n\tgraphicGapMatchInteraction: { name: 'default-graphic-gap-match', tagName: 'pie-qti-graphic-gap-match' },\n\tgraphicOrderInteraction: { name: 'default-graphic-order', tagName: 'pie-qti-graphic-order' },\n\tgraphicAssociateInteraction: { name: 'default-graphic-associate', tagName: 'pie-qti-graphic-associate' },\n\tselectPointInteraction: { name: 'default-select-point', tagName: 'pie-qti-select-point' },\n\textendedTextInteraction: { name: 'default-extended-text', tagName: 'pie-qti-extended-text' },\n\tuploadInteraction: { name: 'default-upload', tagName: 'pie-qti-upload' },\n\tdrawingInteraction: { name: 'default-drawing', tagName: 'pie-qti-drawing' },\n\tcatalogPopup: { name: 'default-catalog-popup', tagName: 'pie-qti-catalog-popup' },\n} satisfies Record<string, { name: string; tagName: string }>;\n\n/**\n * Registry for web components that render QTI interactions\n */\nexport class ComponentRegistry {\n\tprivate components = new Map<string, RegisteredComponent[]>();\n\tprivate definedElements = new Set<string>();\n\n\t/**\n\t * Register a web component for an interaction type with priority-based dispatch\n\t *\n\t * @param type - QTI interaction type (e.g., 'choiceInteraction', 'textEntryInteraction')\n\t * @param config - Component configuration with priority and canHandle predicate\n\t *\n\t * @example\n\t * // Custom rating choice component with high priority\n\t * registry.register('choiceInteraction', {\n\t * name: 'rating-choice',\n\t * priority: 100,\n\t * description: 'Star rating interactions',\n\t * canHandle: (data) => data.interactionClasses?.includes('rating-interaction'),\n\t * tagName: 'custom-rating-choice',\n\t * componentClass: RatingChoiceInteraction,\n\t * autoRegister: true\n\t * });\n\t *\n\t * // Default choice component\n\t * registry.register('choiceInteraction', {\n\t * name: 'standard-choice',\n\t * tagName: 'qti-choice-interaction'\n\t * });\n\t */\n\tregister<TData extends InteractionData>(\n\t\ttype: string,\n\t\tconfig: ComponentConfig<TData>\n\t): void {\n\t\t// Validate tag name\n\t\tif (!config.tagName.includes('-')) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid tag name '${config.tagName}'. ` +\n\t\t\t\t\t`Web component tag names must contain a hyphen.`\n\t\t\t);\n\t\t}\n\n\t\t// Auto-register custom element if requested\n\t\tif (config.componentClass && config.autoRegister !== false) {\n\t\t\tif (!this.definedElements.has(config.tagName)) {\n\t\t\t\tif (!customElements.get(config.tagName)) {\n\t\t\t\t\tcustomElements.define(config.tagName, config.componentClass);\n\t\t\t\t}\n\t\t\t\tthis.definedElements.add(config.tagName);\n\t\t\t}\n\t\t}\n\n\t\t// Get or create component array for this type\n\t\tlet components = this.components.get(type);\n\t\tif (!components) {\n\t\t\tcomponents = [];\n\t\t\tthis.components.set(type, components);\n\t\t}\n\n\t\t// Add normalized component and sort by priority (highest first)\n\t\tcomponents.push(this.createRegisteredComponent(config) as RegisteredComponent);\n\t\tcomponents.sort((a, b) => b.config.priority - a.config.priority);\n\t}\n\n\tprivate createRegisteredComponent<TData extends InteractionData>(\n\t\tconfig: ComponentConfig<TData>\n\t): RegisteredComponent<TData> {\n\t\treturn {\n\t\t\tconfig: {\n\t\t\t\t...config,\n\t\t\t\tpriority: config.priority ?? 0,\n\t\t\t\tcanHandle: config.canHandle ?? (() => true),\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Get a web component tag name for an interaction type\n\t * Evaluates canHandle predicates in priority order\n\t *\n\t * @param data - Interaction data\n\t * @returns Web component tag name (e.g., 'qti-choice-interaction')\n\t * @throws Error if no component matches\n\t */\n\tgetTagName<TData extends InteractionData>(data: TData): string {\n\t\tconst components = this.components.get(data.type);\n\n\t\tif (!components || components.length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`No component registered for '${data.type}' interaction. ` +\n\t\t\t\t\t`Available types: ${Array.from(this.components.keys()).join(', ')}`\n\t\t\t);\n\t\t}\n\n\t\t// Evaluate canHandle in priority order\n\t\tfor (const { config } of components) {\n\t\t\ttry {\n\t\t\t\tif (config.canHandle(data as any)) {\n\t\t\t\t\treturn config.tagName;\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\t// Log but continue to next component\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`canHandle() failed for '${config.name}' component:`,\n\t\t\t\t\terror\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// No component matched\n\t\tconst componentList = components\n\t\t\t.map((c) => {\n\t\t\t\tconst desc = c.config.description ? ` (${c.config.description})` : '';\n\t\t\t\treturn `${c.config.name}${desc}`;\n\t\t\t})\n\t\t\t.join(', ');\n\n\t\tthrow new Error(\n\t\t\t`No component available for '${data.type}' interaction.\\n` +\n\t\t\t\t`Registered components: ${componentList}.\\n` +\n\t\t\t\t`None of these components matched the current interaction.`\n\t\t);\n\t}\n\n\t/**\n\t * Get all registered interaction types\n\t * @returns Array of registered interaction type names\n\t */\n\tgetRegisteredTypes(): string[] {\n\t\treturn Array.from(this.components.keys());\n\t}\n\n\t/**\n\t * Check if a component is registered for a type\n\t */\n\thasComponent(type: string): boolean {\n\t\treturn this.components.has(type) && this.components.get(type)!.length > 0;\n\t}\n\n\t/**\n\t * Get the tag name for a registered type by name (no canHandle evaluation).\n\t * Useful for non-interaction components like catalogPopup where the type string\n\t * is known and there is no InteractionData object to pass.\n\t *\n\t * Returns the highest-priority registered tag name for the type, or null if\n\t * the type is not registered.\n\t */\n\tgetTagNameForType(type: string): string | null {\n\t\tconst components = this.components.get(type);\n\t\tif (!components || components.length === 0) return null;\n\t\treturn components[0].config.tagName;\n\t}\n}\n\n/**\n * Create a new component registry\n */\nexport function createComponentRegistry(): ComponentRegistry {\n\tconst registry = new ComponentRegistry();\n\tregisterDefaultComponentTags(registry);\n\treturn registry;\n}\n\n/**\n * Register the default QTI interaction tag names without importing their implementations.\n *\n * Hosts still choose the implementation bundle, typically by importing\n * `@pie-qti/default-components/plugins` in the browser. Keeping only tag metadata here lets\n * the item-player custom element remain the public rendering boundary without depending on\n * Svelte-authored default components.\n */\nexport function registerDefaultComponentTags(registry: ComponentRegistry): void {\n\tfor (const [type, component] of Object.entries(DEFAULT_COMPONENT_TAGS_BY_TYPE)) {\n\t\tregistry.register(type, {\n\t\t\t...component,\n\t\t\tdescription: `Default web component tag for ${type}`,\n\t\t\tpriority: -100,\n\t\t});\n\t}\n}\n\n/**\n * Plugin interface for registering web components\n */\nexport interface ComponentPlugin {\n\t/** Plugin name (e.g., '@renaissance/rating-choice') */\n\tname: string;\n\n\t/** Plugin version (semver) */\n\tversion: string;\n\n\t/** Plugin description */\n\tdescription: string;\n\n\t/**\n\t * Register web components with the registry\n\t * @param registry - ComponentRegistry instance\n\t */\n\tregister(registry: ComponentRegistry): void;\n}\n"]}
@@ -225,14 +225,18 @@ export declare class Player {
225
225
  private serializeItemSession;
226
226
  private serializeVariable;
227
227
  private qtiValueToSerializable;
228
+ private qtiValueToPublic;
228
229
  private updateDuration;
229
230
  private freezeDuration;
230
231
  private getDuration;
231
232
  private parseDefaultValue;
232
233
  private parseCorrectResponse;
234
+ private parseDeclarationValues;
233
235
  private parseMapping;
234
236
  private parseAreaMapping;
235
237
  private coerceToDeclarationValue;
238
+ private getExtendedTextBase;
239
+ private coerceRecordValue;
236
240
  private collectOutcomes;
237
241
  private renderPrintedVariables;
238
242
  private renderHtmlContent;