@pie-qti/item-player 0.1.14 → 0.1.16

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 (90) hide show
  1. package/README.md +18 -6
  2. package/dist/components/utils/feedbackUtils.js +19 -8
  3. package/dist/components/utils/feedbackUtils.js.map +1 -1
  4. package/dist/core/ComponentRegistry.js +1 -0
  5. package/dist/core/ComponentRegistry.js.map +1 -1
  6. package/dist/core/Player.d.ts +4 -0
  7. package/dist/core/Player.js +296 -89
  8. package/dist/core/Player.js.map +1 -1
  9. package/dist/core/declarations.js +11 -4
  10. package/dist/core/declarations.js.map +1 -1
  11. package/dist/core/sanitizer.js +119 -1
  12. package/dist/core/sanitizer.js.map +1 -1
  13. package/dist/core/shuffle.d.ts +42 -0
  14. package/dist/core/shuffle.js +83 -0
  15. package/dist/core/shuffle.js.map +1 -0
  16. package/dist/core/urlPolicy.js +34 -23
  17. package/dist/core/urlPolicy.js.map +1 -1
  18. package/dist/element-class-hT-bDysz.js +6808 -0
  19. package/dist/element-class-hT-bDysz.js.map +1 -0
  20. package/dist/element-class.d.ts +73 -0
  21. package/dist/element-class.js +2 -0
  22. package/dist/element.d.ts +6 -40
  23. package/dist/element.js +4 -6296
  24. package/dist/element.js.map +1 -1
  25. package/dist/extraction/ExtractionRegistry.js +1 -1
  26. package/dist/extraction/ExtractionRegistry.js.map +1 -1
  27. package/dist/extraction/createContext.d.ts +1 -1
  28. package/dist/extraction/createContext.js +5 -1
  29. package/dist/extraction/createContext.js.map +1 -1
  30. package/dist/extraction/interactionExtractionPipeline.d.ts +6 -1
  31. package/dist/extraction/interactionExtractionPipeline.js +6 -3
  32. package/dist/extraction/interactionExtractionPipeline.js.map +1 -1
  33. package/dist/extraction/types.d.ts +10 -0
  34. package/dist/extraction/types.js.map +1 -1
  35. package/dist/index.d.ts +2 -2
  36. package/dist/index.js +1 -1
  37. package/dist/index.js.map +1 -1
  38. package/dist/interactions/associate/extractor.js +2 -1
  39. package/dist/interactions/associate/extractor.js.map +1 -1
  40. package/dist/interactions/choice/extractor.js +2 -1
  41. package/dist/interactions/choice/extractor.js.map +1 -1
  42. package/dist/interactions/custom/extractor.js +22 -2
  43. package/dist/interactions/custom/extractor.js.map +1 -1
  44. package/dist/interactions/extended-text/extractor.d.ts +6 -0
  45. package/dist/interactions/extended-text/extractor.js +40 -6
  46. package/dist/interactions/extended-text/extractor.js.map +1 -1
  47. package/dist/interactions/extended-text/index.d.ts +1 -0
  48. package/dist/interactions/extended-text/index.js +1 -0
  49. package/dist/interactions/extended-text/index.js.map +1 -1
  50. package/dist/interactions/extended-text/response.d.ts +31 -0
  51. package/dist/interactions/extended-text/response.js +193 -0
  52. package/dist/interactions/extended-text/response.js.map +1 -0
  53. package/dist/interactions/gap-match/extractor.js +8 -7
  54. package/dist/interactions/gap-match/extractor.js.map +1 -1
  55. package/dist/interactions/inline-choice/extractor.js +2 -1
  56. package/dist/interactions/inline-choice/extractor.js.map +1 -1
  57. package/dist/interactions/match/extractor.js +3 -2
  58. package/dist/interactions/match/extractor.js.map +1 -1
  59. package/dist/interactions/modules.d.ts +4 -0
  60. package/dist/interactions/modules.js +2 -0
  61. package/dist/interactions/modules.js.map +1 -1
  62. package/dist/interactions/order/extractor.js +2 -1
  63. package/dist/interactions/order/extractor.js.map +1 -1
  64. package/dist/interactions/portable-custom/extractor.d.ts +3 -2
  65. package/dist/interactions/portable-custom/extractor.js +66 -25
  66. package/dist/interactions/portable-custom/extractor.js.map +1 -1
  67. package/dist/interactions/portable-custom/index.d.ts +1 -1
  68. package/dist/interactions/portable-custom/index.js.map +1 -1
  69. package/dist/interactions/portable-custom/types.d.ts +1 -1
  70. package/dist/interactions/portable-custom/types.js.map +1 -1
  71. package/dist/interactions/position-object/extractor.d.ts +5 -35
  72. package/dist/interactions/position-object/extractor.js +58 -153
  73. package/dist/interactions/position-object/extractor.js.map +1 -1
  74. package/dist/interactions/shared/types.d.ts +15 -1
  75. package/dist/interactions/shared/types.js.map +1 -1
  76. package/dist/pci/PciHost.d.ts +14 -9
  77. package/dist/pci/PciHost.js +89 -22
  78. package/dist/pci/PciHost.js.map +1 -1
  79. package/dist/pci/index.d.ts +3 -0
  80. package/dist/pci/index.js +3 -0
  81. package/dist/pci/index.js.map +1 -0
  82. package/dist/pci/types.d.ts +72 -0
  83. package/dist/pci/types.js +12 -0
  84. package/dist/pci/types.js.map +1 -1
  85. package/dist/presentation/itemPresentationPlan.d.ts +2 -0
  86. package/dist/presentation/itemPresentationPlan.js +6 -0
  87. package/dist/presentation/itemPresentationPlan.js.map +1 -1
  88. package/dist/types/index.d.ts +26 -5
  89. package/dist/types/index.js.map +1 -1
  90. package/package.json +15 -7
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
 
@@ -66,20 +66,26 @@ export function processFeedbackInline(html, options) {
66
66
  const { outcomeValues, applyHeuristics = false, wrapWithSpan = false, transforms } = options;
67
67
  if (!html)
68
68
  return html;
69
- return html.replace(/<feedbackInline[^>]*outcomeIdentifier="([^"]+)"[^>]*identifier="([^"]+)"[^>]*showHide="([^"]+)"[^>]*>([\s\S]*?)<\/feedbackInline>/gi, (match, outcomeId, feedbackId, showHide) => {
70
- const outcomeValue = outcomeValues[outcomeId];
69
+ return html.replace(/<feedbackInline\b([^>]*)>([\s\S]*?)<\/feedbackInline>/gi, (_match, attrs, content) => {
70
+ const outcomeId = feedbackInlineAttr(attrs, 'outcomeIdentifier');
71
+ const feedbackId = feedbackInlineAttr(attrs, 'identifier');
72
+ const showHide = feedbackInlineAttr(attrs, 'showHide') ?? 'show';
73
+ const outcomeValue = outcomeId ? outcomeValues[outcomeId] : undefined;
71
74
  // If outcome value is not set (undefined, null, empty string), hide feedback
72
- if (outcomeValue === undefined || outcomeValue === null || outcomeValue === '') {
75
+ if (outcomeId === null ||
76
+ feedbackId === null ||
77
+ outcomeValue === undefined ||
78
+ outcomeValue === null ||
79
+ outcomeValue === '') {
73
80
  return '';
74
81
  }
75
82
  // Determine if feedback should be shown based on showHide attribute
76
- const shouldShow = showHide.toLowerCase() === 'show'
77
- ? outcomeValue === feedbackId
78
- : outcomeValue !== feedbackId;
83
+ const matchesFeedback = Array.isArray(outcomeValue)
84
+ ? outcomeValue.includes(feedbackId)
85
+ : outcomeValue === feedbackId;
86
+ const shouldShow = showHide.toLowerCase() === 'show' ? matchesFeedback : !matchesFeedback;
79
87
  if (!shouldShow)
80
88
  return '';
81
- // Extract content from feedbackInline tags
82
- let content = match.replace(/<feedbackInline[^>]*>/, '').replace(/<\/feedbackInline>/, '');
83
89
  // Apply text cleaning heuristics if enabled
84
90
  if (applyHeuristics) {
85
91
  content = cleanFeedbackText(content, transforms);
@@ -91,4 +97,9 @@ export function processFeedbackInline(html, options) {
91
97
  return content;
92
98
  });
93
99
  }
100
+ function feedbackInlineAttr(attrs, name) {
101
+ const match = new RegExp(`\\b${name}\\s*=\\s*"([^"]*)"`, 'i').exec(attrs) ??
102
+ new RegExp(`\\b${name}\\s*=\\s*'([^']*)'`, 'i').exec(attrs);
103
+ return match?.[1] ?? null;
104
+ }
94
105
  //# sourceMappingURL=feedbackUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"feedbackUtils.js","sourceRoot":"","sources":["../../../src/components/utils/feedbackUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAYH;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAwB;IAC/D,sEAAsE;IACtE,EAAE,OAAO,EAAE,gCAAgC,EAAE,WAAW,EAAE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f,QAAQ,CAAC,WAAW,EAAE,KAAK,MAAM;YAChC,CAAC,CAAC,YAAY,KAAK,UAAU;YAC7B,CAAC,CAAC,YAAY,KAAK,UAAU,CAAC;QAEhC,IAAI,CAAC,UAAU;YAAE,OAAO,EAAE,CAAC;QAE3B,2CAA2C;QAC3C,IAAI,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;QAE3F,4CAA4C;QAC5C,IAAI,eAAe,EAAE,CAAC;YACrB,OAAO,GAAG,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAClD,CAAC;QAED,oCAAoC;QACpC,IAAI,YAAY,EAAE,CAAC;YAClB,OAAO,sCAAsC,OAAO,SAAS,CAAC;QAC/D,CAAC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC,CACD,CAAC;AACH,CAAC","sourcesContent":["/**\n * Feedback text utilities for QTI items\n *\n * NOTE: The cleanFeedbackText function contains vendor-specific transforms\n * for content that uses semicolons after \"Correct\" and \"Incorrect\" labels.\n * This is common in some QTI authoring tools but not part of the QTI specification.\n *\n * To customize this behavior for your vendor's content, you can:\n * 1. Modify the patterns in this file\n * 2. Create a vendor-specific transform plugin (see VENDOR-TRANSFORM-PLUGIN-GUIDE.md)\n * 3. Pass custom transforms via the feedbackTransforms option\n */\n\n/**\n * Text pattern replacement for feedback content\n */\nexport interface FeedbackTransform {\n\t/** Regular expression to match the pattern */\n\tpattern: RegExp;\n\t/** Replacement string (can use capture groups like $1, $2) */\n\treplacement: string;\n}\n\n/**\n * Default feedback text transforms\n * These are vendor-specific patterns commonly found in certain QTI authoring tools\n */\nexport const DEFAULT_FEEDBACK_TRANSFORMS: FeedbackTransform[] = [\n\t// Remove semicolons after \"Incorrect\" (with or without <strong> tags)\n\t{ pattern: /<strong>Incorrect;<\\/strong>/gi, replacement: '<strong>Incorrect</strong> ' },\n\t{ pattern: /Incorrect;/gi, replacement: 'Incorrect ' },\n\n\t// Remove semicolons after \"Correct\" (with or without <strong> tags)\n\t{ pattern: /<strong>Correct;<\\/strong>/gi, replacement: '<strong>Correct</strong> ' },\n\t{ pattern: /Correct;/gi, replacement: 'Correct ' },\n];\n\n/**\n * Clean up feedback text formatting using configurable transforms\n *\n * @param content - The feedback content HTML string\n * @param transforms - Optional custom transforms (defaults to DEFAULT_FEEDBACK_TRANSFORMS)\n * @returns Cleaned feedback content\n */\nexport function cleanFeedbackText(\n\tcontent: string,\n\ttransforms: FeedbackTransform[] = DEFAULT_FEEDBACK_TRANSFORMS\n): string {\n\tif (!content) return content;\n\n\tlet result = content;\n\tfor (const transform of transforms) {\n\t\tresult = result.replace(transform.pattern, transform.replacement);\n\t}\n\n\treturn result;\n}\n\n/**\n * Default outcome identifier for feedback display\n * This can be overridden if your QTI content uses a different identifier\n */\nexport const DEFAULT_FEEDBACK_OUTCOME_ID = 'FEEDBACK';\n\n/**\n * Options for processing feedbackInline elements\n */\nexport interface ProcessFeedbackInlineOptions {\n\t/** Outcome values from response processing */\n\toutcomeValues: Record<string, any>;\n\t/** Whether to apply feedback text cleaning heuristics */\n\tapplyHeuristics?: boolean;\n\t/** Whether to wrap feedback content with qti-feedback-inline span */\n\twrapWithSpan?: boolean;\n\t/** Custom feedback transforms (defaults to DEFAULT_FEEDBACK_TRANSFORMS) */\n\ttransforms?: FeedbackTransform[];\n}\n\n/**\n * Process feedbackInline elements in QTI content\n *\n * Conditionally shows/hides feedback based on outcome values and the showHide attribute.\n * Optionally applies text cleaning heuristics and wraps content with styling span.\n *\n * @param html - The HTML content containing feedbackInline elements\n * @param options - Processing options\n * @returns Modified HTML with processed feedbackInline elements\n *\n * @example\n * ```typescript\n * const html = processFeedbackInline(content, {\n * outcomeValues: { FEEDBACK: 'choiceA' },\n * applyHeuristics: true,\n * wrapWithSpan: true\n * });\n * ```\n */\nexport function processFeedbackInline(\n\thtml: string,\n\toptions: ProcessFeedbackInlineOptions\n): string {\n\tconst { outcomeValues, applyHeuristics = false, wrapWithSpan = false, transforms } = options;\n\n\tif (!html) return html;\n\n\treturn html.replace(\n\t\t/<feedbackInline[^>]*outcomeIdentifier=\"([^\"]+)\"[^>]*identifier=\"([^\"]+)\"[^>]*showHide=\"([^\"]+)\"[^>]*>([\\s\\S]*?)<\\/feedbackInline>/gi,\n\t\t(match, outcomeId, feedbackId, showHide) => {\n\t\t\tconst outcomeValue = outcomeValues[outcomeId];\n\n\t\t\t// If outcome value is not set (undefined, null, empty string), hide feedback\n\t\t\tif (outcomeValue === undefined || outcomeValue === null || outcomeValue === '') {\n\t\t\t\treturn '';\n\t\t\t}\n\n\t\t\t// Determine if feedback should be shown based on showHide attribute\n\t\t\tconst shouldShow =\n\t\t\t\tshowHide.toLowerCase() === 'show'\n\t\t\t\t\t? outcomeValue === feedbackId\n\t\t\t\t\t: outcomeValue !== feedbackId;\n\n\t\t\tif (!shouldShow) return '';\n\n\t\t\t// Extract content from feedbackInline tags\n\t\t\tlet content = match.replace(/<feedbackInline[^>]*>/, '').replace(/<\\/feedbackInline>/, '');\n\n\t\t\t// Apply text cleaning heuristics if enabled\n\t\t\tif (applyHeuristics) {\n\t\t\t\tcontent = cleanFeedbackText(content, transforms);\n\t\t\t}\n\n\t\t\t// Wrap with styling span if enabled\n\t\t\tif (wrapWithSpan) {\n\t\t\t\treturn ` <span class=\"qti-feedback-inline\">${content}</span>`;\n\t\t\t}\n\n\t\t\treturn content;\n\t\t}\n\t);\n}\n"]}
1
+ {"version":3,"file":"feedbackUtils.js","sourceRoot":"","sources":["../../../src/components/utils/feedbackUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAYH;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAwB;IAC/D,sEAAsE;IACtE,EAAE,OAAO,EAAE,gCAAgC,EAAE,WAAW,EAAE,6BAA6B,EAAE;IACzF,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE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,CAAC;QAEtE,6EAA6E;QAC7E,IACC,SAAS,KAAK,IAAI;YAClB,UAAU,KAAK,IAAI;YACnB,YAAY,KAAK,SAAS;YAC1B,YAAY,KAAK,IAAI;YACrB,YAAY,KAAK,EAAE,EAClB,CAAC;YACF,OAAO,EAAE,CAAC;QACX,CAAC;QAED,oEAAoE;QACpE,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC;YAClD,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC;YACnC,CAAC,CAAC,YAAY,KAAK,UAAU,CAAC;QAC/B,MAAM,UAAU,GACf,QAAQ,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC;QAExE,IAAI,CAAC,UAAU;YAAE,OAAO,EAAE,CAAC;QAE3B,4CAA4C;QAC5C,IAAI,eAAe,EAAE,CAAC;YACrB,OAAO,GAAG,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAClD,CAAC;QAED,oCAAoC;QACpC,IAAI,YAAY,EAAE,CAAC;YAClB,OAAO,sCAAsC,OAAO,SAAS,CAAC;QAC/D,CAAC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC,CACD,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAa,EAAE,IAAY;IACtD,MAAM,KAAK,GACV,IAAI,MAAM,CAAC,MAAM,IAAI,oBAAoB,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;QAC3D,IAAI,MAAM,CAAC,MAAM,IAAI,oBAAoB,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7D,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAC3B,CAAC","sourcesContent":["/**\n * Feedback text utilities for QTI items\n *\n * NOTE: The cleanFeedbackText function contains vendor-specific transforms\n * for content that uses semicolons after \"Correct\" and \"Incorrect\" labels.\n * This is common in some QTI authoring tools but not part of the QTI specification.\n *\n * To customize this behavior for your vendor's content, you can:\n * 1. Modify the patterns in this file\n * 2. Create a vendor-specific transform plugin (see VENDOR-TRANSFORM-PLUGIN-GUIDE.md)\n * 3. Pass custom transforms via the feedbackTransforms option\n */\n\n/**\n * Text pattern replacement for feedback content\n */\nexport interface FeedbackTransform {\n\t/** Regular expression to match the pattern */\n\tpattern: RegExp;\n\t/** Replacement string (can use capture groups like $1, $2) */\n\treplacement: string;\n}\n\n/**\n * Default feedback text transforms\n * These are vendor-specific patterns commonly found in certain QTI authoring tools\n */\nexport const DEFAULT_FEEDBACK_TRANSFORMS: FeedbackTransform[] = [\n\t// Remove semicolons after \"Incorrect\" (with or without <strong> tags)\n\t{ pattern: /<strong>Incorrect;<\\/strong>/gi, replacement: '<strong>Incorrect</strong> ' },\n\t{ pattern: /Incorrect;/gi, replacement: 'Incorrect ' },\n\n\t// Remove semicolons after \"Correct\" (with or without <strong> tags)\n\t{ pattern: /<strong>Correct;<\\/strong>/gi, replacement: '<strong>Correct</strong> ' },\n\t{ pattern: /Correct;/gi, replacement: 'Correct ' },\n];\n\n/**\n * Clean up feedback text formatting using configurable transforms\n *\n * @param content - The feedback content HTML string\n * @param transforms - Optional custom transforms (defaults to DEFAULT_FEEDBACK_TRANSFORMS)\n * @returns Cleaned feedback content\n */\nexport function cleanFeedbackText(\n\tcontent: string,\n\ttransforms: FeedbackTransform[] = DEFAULT_FEEDBACK_TRANSFORMS\n): string {\n\tif (!content) return content;\n\n\tlet result = content;\n\tfor (const transform of transforms) {\n\t\tresult = result.replace(transform.pattern, transform.replacement);\n\t}\n\n\treturn result;\n}\n\n/**\n * Default outcome identifier for feedback display\n * This can be overridden if your QTI content uses a different identifier\n */\nexport const DEFAULT_FEEDBACK_OUTCOME_ID = 'FEEDBACK';\n\n/**\n * Options for processing feedbackInline elements\n */\nexport interface ProcessFeedbackInlineOptions {\n\t/** Outcome values from response processing */\n\toutcomeValues: Record<string, any>;\n\t/** Whether to apply feedback text cleaning heuristics */\n\tapplyHeuristics?: boolean;\n\t/** Whether to wrap feedback content with qti-feedback-inline span */\n\twrapWithSpan?: boolean;\n\t/** Custom feedback transforms (defaults to DEFAULT_FEEDBACK_TRANSFORMS) */\n\ttransforms?: FeedbackTransform[];\n}\n\n/**\n * Process feedbackInline elements in QTI content\n *\n * Conditionally shows/hides feedback based on outcome values and the showHide attribute.\n * Optionally applies text cleaning heuristics and wraps content with styling span.\n *\n * @param html - The HTML content containing feedbackInline elements\n * @param options - Processing options\n * @returns Modified HTML with processed feedbackInline elements\n *\n * @example\n * ```typescript\n * const html = processFeedbackInline(content, {\n * outcomeValues: { FEEDBACK: 'choiceA' },\n * applyHeuristics: true,\n * wrapWithSpan: true\n * });\n * ```\n */\nexport function processFeedbackInline(\n\thtml: string,\n\toptions: ProcessFeedbackInlineOptions\n): string {\n\tconst { outcomeValues, applyHeuristics = false, wrapWithSpan = false, transforms } = options;\n\n\tif (!html) return html;\n\n\treturn html.replace(\n\t\t/<feedbackInline\\b([^>]*)>([\\s\\S]*?)<\\/feedbackInline>/gi,\n\t\t(_match, attrs, content) => {\n\t\t\tconst outcomeId = feedbackInlineAttr(attrs, 'outcomeIdentifier');\n\t\t\tconst feedbackId = feedbackInlineAttr(attrs, 'identifier');\n\t\t\tconst showHide = feedbackInlineAttr(attrs, 'showHide') ?? 'show';\n\t\t\tconst outcomeValue = outcomeId ? outcomeValues[outcomeId] : undefined;\n\n\t\t\t// If outcome value is not set (undefined, null, empty string), hide feedback\n\t\t\tif (\n\t\t\t\toutcomeId === null ||\n\t\t\t\tfeedbackId === null ||\n\t\t\t\toutcomeValue === undefined ||\n\t\t\t\toutcomeValue === null ||\n\t\t\t\toutcomeValue === ''\n\t\t\t) {\n\t\t\t\treturn '';\n\t\t\t}\n\n\t\t\t// Determine if feedback should be shown based on showHide attribute\n\t\t\tconst matchesFeedback = Array.isArray(outcomeValue)\n\t\t\t\t? outcomeValue.includes(feedbackId)\n\t\t\t\t: outcomeValue === feedbackId;\n\t\t\tconst shouldShow =\n\t\t\t\tshowHide.toLowerCase() === 'show' ? matchesFeedback : !matchesFeedback;\n\n\t\t\tif (!shouldShow) return '';\n\n\t\t\t// Apply text cleaning heuristics if enabled\n\t\t\tif (applyHeuristics) {\n\t\t\t\tcontent = cleanFeedbackText(content, transforms);\n\t\t\t}\n\n\t\t\t// Wrap with styling span if enabled\n\t\t\tif (wrapWithSpan) {\n\t\t\t\treturn ` <span class=\"qti-feedback-inline\">${content}</span>`;\n\t\t\t}\n\n\t\t\treturn content;\n\t\t}\n\t);\n}\n\nfunction feedbackInlineAttr(attrs: string, name: string): string | null {\n\tconst match =\n\t\tnew RegExp(`\\\\b${name}\\\\s*=\\\\s*\"([^\"]*)\"`, 'i').exec(attrs) ??\n\t\tnew RegExp(`\\\\b${name}\\\\s*=\\\\s*'([^']*)'`, 'i').exec(attrs);\n\treturn match?.[1] ?? null;\n}\n"]}
@@ -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":"AAAA;;;;;;GAMG;AA6DH,MAAM,8BAA8B,GAAG;IACtC,iBAAiB,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,OA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O,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,yBAAyB,EAAE,EAAE,IAAI,EAAE,yBAAyB,EAAE,OAAO,EAAE,yBAAyB,EAAE;IAClG,0BAA0B,EAAE,EAAE,IAAI,EAA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,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;