@pie-qti/item-player 0.1.27 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +35 -6
  2. package/dist/catalog/applyGlossaryTriggers.js +8 -2
  3. package/dist/catalog/applyGlossaryTriggers.js.map +1 -1
  4. package/dist/catalog/catalogExtractor.js +44 -7
  5. package/dist/catalog/catalogExtractor.js.map +1 -1
  6. package/dist/catalog/catalogLookup.d.ts +8 -0
  7. package/dist/catalog/catalogLookup.js +17 -0
  8. package/dist/catalog/catalogLookup.js.map +1 -1
  9. package/dist/catalog/types.d.ts +3 -3
  10. package/dist/catalog/types.js.map +1 -1
  11. package/dist/components/utils/feedbackUtils.d.ts +9 -4
  12. package/dist/components/utils/feedbackUtils.js +67 -34
  13. package/dist/components/utils/feedbackUtils.js.map +1 -1
  14. package/dist/core/AssessmentItemDefinition.js +35 -0
  15. package/dist/core/AssessmentItemDefinition.js.map +1 -1
  16. package/dist/core/ItemSession.d.ts +19 -1
  17. package/dist/core/ItemSession.js +12 -2
  18. package/dist/core/ItemSession.js.map +1 -1
  19. package/dist/core/Player.d.ts +41 -1
  20. package/dist/core/Player.js +216 -48
  21. package/dist/core/Player.js.map +1 -1
  22. package/dist/core/sanitizer.js +16 -3
  23. package/dist/core/sanitizer.js.map +1 -1
  24. package/dist/document/AssessmentItemDocument.d.ts +12 -5
  25. package/dist/document/AssessmentItemDocument.js +28 -19
  26. package/dist/document/AssessmentItemDocument.js.map +1 -1
  27. package/dist/document/contentPass.d.ts +17 -0
  28. package/dist/document/contentPass.js +40 -0
  29. package/dist/document/contentPass.js.map +1 -0
  30. package/dist/document/printedVariable.d.ts +35 -0
  31. package/dist/document/printedVariable.js +215 -0
  32. package/dist/document/printedVariable.js.map +1 -0
  33. package/dist/{element-class-BzATCyhV.js → element-class-D-kJi_w9.js} +3211 -2125
  34. package/dist/element-class-D-kJi_w9.js.map +1 -0
  35. package/dist/element-class.js +1 -1
  36. package/dist/element.js +1 -1
  37. package/dist/extraction/interactionAccessibility.d.ts +14 -0
  38. package/dist/extraction/interactionAccessibility.js +58 -0
  39. package/dist/extraction/interactionAccessibility.js.map +1 -0
  40. package/dist/extraction/interactionExtractionPipeline.d.ts +4 -1
  41. package/dist/extraction/interactionExtractionPipeline.js +7 -2
  42. package/dist/extraction/interactionExtractionPipeline.js.map +1 -1
  43. package/dist/extraction/utils.js +20 -1
  44. package/dist/extraction/utils.js.map +1 -1
  45. package/dist/index.d.ts +9 -3
  46. package/dist/index.js +4 -0
  47. package/dist/index.js.map +1 -1
  48. package/dist/interactions/order/extractor.js +2 -0
  49. package/dist/interactions/order/extractor.js.map +1 -1
  50. package/dist/interactions/portable-custom/extractor.js +47 -11
  51. package/dist/interactions/portable-custom/extractor.js.map +1 -1
  52. package/dist/interactions/shared/types.d.ts +16 -0
  53. package/dist/interactions/shared/types.js.map +1 -1
  54. package/dist/pci/PciHost.d.ts +85 -43
  55. package/dist/pci/PciHost.js +229 -148
  56. package/dist/pci/PciHost.js.map +1 -1
  57. package/dist/pci/allowlistResolver.d.ts +10 -1
  58. package/dist/pci/allowlistResolver.js +43 -4
  59. package/dist/pci/allowlistResolver.js.map +1 -1
  60. package/dist/pci/amdLoader.d.ts +23 -0
  61. package/dist/pci/amdLoader.js +190 -0
  62. package/dist/pci/amdLoader.js.map +1 -0
  63. package/dist/pci/index.d.ts +14 -3
  64. package/dist/pci/index.js +8 -1
  65. package/dist/pci/index.js.map +1 -1
  66. package/dist/pci/moduleSession.d.ts +41 -0
  67. package/dist/pci/moduleSession.js +2 -0
  68. package/dist/pci/moduleSession.js.map +1 -0
  69. package/dist/pci/pageRealmSession.d.ts +49 -0
  70. package/dist/pci/pageRealmSession.js +193 -0
  71. package/dist/pci/pageRealmSession.js.map +1 -0
  72. package/dist/pci/qtiVariableJson.d.ts +7 -0
  73. package/dist/pci/qtiVariableJson.js +93 -0
  74. package/dist/pci/qtiVariableJson.js.map +1 -0
  75. package/dist/pci/registry.d.ts +15 -0
  76. package/dist/pci/registry.js +77 -0
  77. package/dist/pci/registry.js.map +1 -0
  78. package/dist/pci/resolutionConfig.d.ts +23 -0
  79. package/dist/pci/resolutionConfig.js +63 -0
  80. package/dist/pci/resolutionConfig.js.map +1 -0
  81. package/dist/pci/sandbox/SandboxedPciSession.d.ts +78 -0
  82. package/dist/pci/sandbox/SandboxedPciSession.js +332 -0
  83. package/dist/pci/sandbox/SandboxedPciSession.js.map +1 -0
  84. package/dist/pci/sandbox/iframeConnector.d.ts +13 -0
  85. package/dist/pci/sandbox/iframeConnector.js +94 -0
  86. package/dist/pci/sandbox/iframeConnector.js.map +1 -0
  87. package/dist/pci/sandbox/protocol.d.ts +117 -0
  88. package/dist/pci/sandbox/protocol.js +49 -0
  89. package/dist/pci/sandbox/protocol.js.map +1 -0
  90. package/dist/pci/types.d.ts +213 -30
  91. package/dist/pci/types.js +8 -1
  92. package/dist/pci/types.js.map +1 -1
  93. package/dist/pnp/applyPnp.d.ts +3 -4
  94. package/dist/pnp/applyPnp.js +54 -8
  95. package/dist/pnp/applyPnp.js.map +1 -1
  96. package/dist/pnp/parsePnpXml.d.ts +2 -2
  97. package/dist/pnp/parsePnpXml.js +146 -4
  98. package/dist/pnp/parsePnpXml.js.map +1 -1
  99. package/dist/pnp/types.d.ts +57 -0
  100. package/dist/pnp/types.js.map +1 -1
  101. package/dist/presentation/itemPresentationPlan.d.ts +12 -1
  102. package/dist/presentation/itemPresentationPlan.js +11 -3
  103. package/dist/presentation/itemPresentationPlan.js.map +1 -1
  104. package/dist/server.d.ts +5 -0
  105. package/dist/server.js.map +1 -1
  106. package/dist/types/index.d.ts +5 -0
  107. package/dist/types/index.js.map +1 -1
  108. package/package.json +6 -6
  109. package/dist/element-class-BzATCyhV.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"itemPresentationPlan.js","sourceRoot":"","sources":["../../src/presentation/itemPresentationPlan.ts"],"names":[],"mappings":"AACA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CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,gBAAgB,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;YACvC,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,IAAI,EAAiC,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,WAAgC;IAC9D,MAAM,cAAc,GAAG,WAAkB,CAAC;IAC1C,MAAM,GAAG,GACR,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,IAAI,cAAc,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QAC1E,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAW,EAAE,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC3F,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,MAAM,GAAG,OAAO,cAAc,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACvF,OAAO,GAAG,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,UAAU,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;AACzE,CAAC","sourcesContent":["import type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';\nimport {\n\tnormalizeHeuristicsConfig,\n\ttype QtiHeuristicsConfig,\n} from '@pie-qti/ims-cp-core';\nimport { parse } from 'node-html-parser';\nimport type { HTMLElement as ParsedHtmlElement } from 'node-html-parser';\nimport type { ComponentRegistry } from '../core/ComponentRegistry.js';\nimport { sanitizeHtml } from '../core/sanitizer.js';\nimport { htmlToString, toTrustedHtml } from '../core/trustedTypes.js';\nimport type { PnpProfile } from '../pnp/types.js';\nimport { getRoleCapabilities, type RoleCapabilities } from '../core/rolePolicy.js';\nimport type {\n\tHtmlContent,\n\tPlayerSecurityConfig,\n\tQTIRole,\n\tRubricBlock,\n} from '../types/index.js';\nimport { processFeedbackInline } from '../components/utils/feedbackUtils.js';\nimport { buildScopedStylesheetCss } from '../components/utils/stylesheetRender.js';\nimport { buildEffectiveStimulusContent, injectStimulusContent } from '../components/utils/stimulusRender.js';\nimport {\n\tcreateInlineRenderPlan,\n\tisInlineInteractionTagName,\n\tisInlineInteractionType,\n} from '../interactions/inline/render-plan.js';\nimport type {\n\tBaseInteractionData,\n\tInlineChoiceInteractionData,\n\tTextEntryInteractionData,\n} from '../interactions/shared/types.js';\n\nexport type ItemPresentationResponseValue = unknown;\nexport type ItemPresentationResponseMap = Record<string, ItemPresentationResponseValue>;\n\n/**\n * Immutable inputs captured from the live item session for one presentation pass.\n *\n * This deliberately contains data rather than a Player-shaped adapter. Presentation\n * cannot reach back into the session midway through a render, and its only live seam\n * is the real component registry used to resolve plugin renderers.\n */\nexport interface ItemPresentationSource {\n\titemBodyHtml: HtmlContent;\n\tinteractions: readonly BaseInteractionData[];\n\tcorrectResponses: Record<string, unknown>;\n\tcomponentRegistry: ComponentRegistry;\n\tdeliveryContext?: ResolvedItemDeliveryContext;\n\tpnp?: PnpProfile;\n\tsecurity?: PlayerSecurityConfig;\n\t/** Role-filtered, finalized direct rubrics for host placement. */\n\tdirectRubrics?: readonly RubricBlock[];\n}\n\nexport interface CreateItemPresentationOptions {\n\tsource: ItemPresentationSource;\n\tresponses?: ItemPresentationResponseMap;\n\tdisabled?: boolean;\n\trole?: QTIRole;\n\toutcomeValues?: Record<string, unknown>;\n\theuristicsConfig?: QtiHeuristicsConfig;\n\titemBodyScopeSelector?: string;\n\trenderItemBodyRubrics?: boolean;\n\tonComponentError?: (interaction: BaseInteractionData, error: unknown) => void;\n}\n\nexport interface BlockInteractionMount {\n\treadonly placement: 'block';\n\treadonly renderer: 'web-component';\n\treadonly interaction: BaseInteractionData;\n\treadonly tagName: string;\n\treadonly key: string;\n\treadonly response: ItemPresentationResponseValue | null;\n\t/** Lexical companion value used by extendedTextInteraction stringIdentifier. */\n\treadonly stringResponse?: ItemPresentationResponseValue | null;\n\treadonly correctResponse: unknown;\n\treadonly pnp: PnpProfile | undefined;\n\treadonly eliminationTool: boolean;\n\treadonly disabled: boolean;\n\treadonly componentRole: 'scorer' | undefined;\n}\n\nexport type InlineInteractionMount =\n\t| {\n\t\t\treadonly placement: 'inline';\n\t\t\treadonly renderer: 'text-entry';\n\t\t\treadonly interaction: TextEntryInteractionData;\n\t }\n\t| {\n\t\t\treadonly placement: 'inline';\n\t\t\treadonly renderer: 'inline-choice';\n\t\t\treadonly interaction: InlineChoiceInteractionData;\n\t };\n\nexport type ItemInteractionMount = InlineInteractionMount | BlockInteractionMount;\n\ndeclare const finalItemBodyHtmlBrand: unique symbol;\n\n/** HTML that has completed every body transform, sanitation, and Trusted Types finalization. */\nexport type FinalItemBodyHtml = HtmlContent & {\n\treadonly [finalItemBodyHtmlBrand]: true;\n};\n\nexport type ItemPresentationFlowNode =\n\t| { readonly kind: 'html'; readonly html: FinalItemBodyHtml }\n\t| { readonly kind: 'interaction'; readonly mount: ItemInteractionMount };\n\nexport interface ItemPresentation {\n\treadonly capabilities: RoleCapabilities;\n\treadonly disabled: boolean;\n\treadonly correctResponses: Readonly<Record<string, unknown>>;\n\t/** Direct assessmentItem rubrics that remain outside the item-body flow. */\n\treadonly directRubrics: readonly RubricBlock[];\n\t/** Ordered, render-neutral body flow. Block mounts follow the authored body HTML. */\n\treadonly flow: readonly ItemPresentationFlowNode[];\n\t/** Policy-checked CSS is kept out of the HTML/Trusted Types pipeline. */\n\treadonly scopedCss: string;\n}\n\nexport function createItemPresentation({\n\tsource,\n\tresponses = {},\n\tdisabled = false,\n\trole = 'candidate',\n\toutcomeValues = {},\n\theuristicsConfig,\n\titemBodyScopeSelector = '[data-qti-item-body-scope]',\n\trenderItemBodyRubrics = true,\n\tonComponentError,\n}: CreateItemPresentationOptions): ItemPresentation {\n\tconst roleCapabilities = getRoleCapabilities(role);\n\tconst effectiveDisabled = disabled || roleCapabilities.isReadOnly;\n\tconst correctResponses = roleCapabilities.canViewCorrectResponses ? source.correctResponses : {};\n\tconst { html, scopedCss } = buildItemBodyPresentation({\n\t\tsource,\n\t\trole,\n\t\toutcomeValues,\n\t\theuristicsConfig,\n\t\titemBodyScopeSelector,\n\t\trenderItemBodyRubrics,\n\t});\n\tconst inlineFlow = createInlineRenderPlan(html, source.interactions).map(\n\t\t(segment): ItemPresentationFlowNode => {\n\t\t\tif (segment.type === 'html') {\n\t\t\t\t// Inline planning parses and reserializes the composed body, so sanitation\n\t\t\t\t// belongs after that final string transform and immediately before TT.\n\t\t\t\tconst sanitized = sanitizeHtml(segment.content, { security: source.security });\n\t\t\t\treturn {\n\t\t\t\t\tkind: 'html',\n\t\t\t\t\thtml: finalizeItemBodyHtml(sanitized, source.security),\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (segment.type === 'textEntry') {\n\t\t\t\treturn {\n\t\t\t\t\tkind: 'interaction',\n\t\t\t\t\tmount: {\n\t\t\t\t\t\tplacement: 'inline',\n\t\t\t\t\t\trenderer: 'text-entry',\n\t\t\t\t\t\tinteraction: segment.interaction,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkind: 'interaction',\n\t\t\t\tmount: {\n\t\t\t\t\tplacement: 'inline',\n\t\t\t\t\trenderer: 'inline-choice',\n\t\t\t\t\tinteraction: segment.interaction,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t);\n\tconst blockFlow = createBlockInteractionMounts({\n\t\tinteractions: source.interactions,\n\t\tsource,\n\t\tresponses,\n\t\tcorrectResponses,\n\t\troleCapabilities,\n\t\teffectiveDisabled,\n\t\tonComponentError,\n\t}).map(\n\t\t(mount): ItemPresentationFlowNode => ({\n\t\t\tkind: 'interaction',\n\t\t\tmount,\n\t\t})\n\t);\n\n\treturn freezePresentation({\n\t\tcapabilities: roleCapabilities,\n\t\tdisabled: effectiveDisabled,\n\t\tcorrectResponses,\n\t\tdirectRubrics: source.directRubrics ?? [],\n\t\tflow: [...inlineFlow, ...blockFlow],\n\t\tscopedCss,\n\t});\n}\n\nfunction freezePresentation<T>(value: T): T {\n\tif (!value || typeof value !== 'object' || Object.isFrozen(value)) return value;\n\tconst prototype = Object.getPrototypeOf(value);\n\tif (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) return value;\n\tObject.freeze(value);\n\tfor (const child of Object.values(value as Record<string, unknown>)) {\n\t\tfreezePresentation(child);\n\t}\n\treturn value;\n}\n\nfunction buildItemBodyPresentation({\n\tsource,\n\trole,\n\toutcomeValues,\n\theuristicsConfig,\n\titemBodyScopeSelector,\n\trenderItemBodyRubrics,\n}: {\n\tsource: ItemPresentationSource;\n\trole: QTIRole;\n\toutcomeValues: Record<string, unknown>;\n\theuristicsConfig: QtiHeuristicsConfig | undefined;\n\titemBodyScopeSelector: string;\n\trenderItemBodyRubrics: boolean;\n}): { html: string; scopedCss: string } {\n\tlet html = htmlToString(source.itemBodyHtml);\n\tconst scopedCss = buildScopedStylesheetCss(source.deliveryContext, itemBodyScopeSelector);\n\tconst effectiveStimulusContent = buildEffectiveStimulusContent(\n\t\tsource.deliveryContext,\n\t\t(content) => sanitizeHtml(content, { security: source.security })\n\t);\n\n\thtml = injectStimulusContent(html, effectiveStimulusContent);\n\thtml = renderRubricBlocksForRole(html, role, { renderRubrics: renderItemBodyRubrics });\n\n\tconst heuristics = normalizeHeuristicsConfig(heuristicsConfig);\n\thtml = processFeedbackInline(html, {\n\t\toutcomeValues,\n\t\tapplyHeuristics: heuristics.feedbackTextFormatting,\n\t\twrapWithSpan: false,\n\t});\n\n\treturn { html: hideBlockInteractionMarkup(html), scopedCss };\n}\n\nfunction finalizeItemBodyHtml(\n\thtml: string,\n\tsecurity: PlayerSecurityConfig | undefined\n): FinalItemBodyHtml {\n\treturn toTrustedHtml(html, security?.trustedTypesPolicyName) as FinalItemBodyHtml;\n}\n\nfunction renderRubricBlocksForRole(\n\thtml: string,\n\trole: QTIRole,\n\t{ renderRubrics }: { renderRubrics: boolean }\n): string {\n\tif (!html || !/rubric-?block/i.test(html)) {\n\t\treturn html;\n\t}\n\n\ttry {\n\t\tconst root = parse(html, { lowerCaseTagName: false, comment: false });\n\t\trenderRubricBlockChildren(root as unknown as ParsedHtmlElement, role, { renderRubrics });\n\t\treturn root.toString();\n\t} catch {\n\t\treturn html;\n\t}\n}\n\nfunction renderRubricBlockChildren(\n\telement: ParsedHtmlElement,\n\trole: QTIRole,\n\t{ renderRubrics }: { renderRubrics: boolean }\n): void {\n\tconst children = [...element.childNodes] as unknown as ParsedHtmlElement[];\n\tfor (const child of children) {\n\t\tconst tagName = child.rawTagName?.toLowerCase();\n\t\tif (\n\t\t\ttagName &&\n\t\t\tisRubricBlockTag(tagName) &&\n\t\t\t(!renderRubrics || !rubricBlockVisibleToRole(child, role))\n\t\t) {\n\t\t\tchild.remove();\n\t\t\tcontinue;\n\t\t}\n\t\tif (child.childNodes?.length) {\n\t\t\trenderRubricBlockChildren(child, role, { renderRubrics });\n\t\t}\n\t\tif (tagName && isRubricBlockTag(tagName)) {\n\t\t\tchild.replaceWith(renderRubricBlockWrapper(child));\n\t\t}\n\t}\n}\n\nfunction isRubricBlockTag(tagName: string): boolean {\n\treturn tagName === 'rubricblock' || tagName === 'qti-rubric-block';\n}\n\nfunction rubricBlockVisibleToRole(element: ParsedHtmlElement, role: QTIRole): boolean {\n\tconst view = element.getAttribute('view')?.trim();\n\tif (!view) {\n\t\treturn true;\n\t}\n\treturn splitRubricView(view).includes(role);\n}\n\nfunction renderRubricBlockWrapper(element: ParsedHtmlElement): string {\n\tconst view = element.getAttribute('view')?.trim();\n\tconst use = element.getAttribute('use')?.trim();\n\tconst attrs = [\n\t\t'class=\"qti-rubric-block\"',\n\t\tview ? `data-qti-rubric-view=\"${escapeHtmlAttribute(view)}\"` : '',\n\t\tuse ? `data-qti-rubric-use=\"${escapeHtmlAttribute(use)}\"` : '',\n\t]\n\t\t.filter(Boolean)\n\t\t.join(' ');\n\treturn `<div ${attrs}>${serializeHtmlChildren(element)}</div>`;\n}\n\nfunction splitRubricView(view: string): string[] {\n\treturn view.split(/[\\s,]+/).filter(Boolean);\n}\n\nfunction serializeHtmlChildren(element: ParsedHtmlElement): string {\n\treturn ([...element.childNodes] as unknown as ParsedHtmlElement[])\n\t\t.map((child) => child.toString())\n\t\t.join('');\n}\n\nfunction escapeHtmlAttribute(value: string): string {\n\treturn value\n\t\t.replace(/&/g, '&amp;')\n\t\t.replace(/\"/g, '&quot;')\n\t\t.replace(/</g, '&lt;')\n\t\t.replace(/>/g, '&gt;');\n}\n\nfunction hideBlockInteractionMarkup(html: string): string {\n\t// positionObjectStage is hidden as a unit: it owns the background object and wraps its\n\t// interactions, all of which the component renders. Matching only the interaction inside it\n\t// would leave the stage's background image visible in the item body as well.\n\treturn html.replace(\n\t\t/<(\\w+Interaction|qti-[\\w-]+-interaction|positionObjectStage|qti-position-object-stage)(\\s[^>]*)?>[\\s\\S]*?<\\/\\1>/gi,\n\t\t(match, tagName) => {\n\t\t\tconst lower = tagName.toLowerCase();\n\t\t\tif (isInlineInteractionTagName(lower)) return match;\n\t\t\treturn `<span class=\"qti-hidden-interaction\">${match}</span>`;\n\t\t}\n\t);\n}\n\nfunction createBlockInteractionMounts({\n\tinteractions,\n\tsource,\n\tresponses,\n\tcorrectResponses,\n\troleCapabilities,\n\teffectiveDisabled,\n\tonComponentError,\n}: {\n\tinteractions: readonly BaseInteractionData[];\n\tsource: ItemPresentationSource;\n\tresponses: ItemPresentationResponseMap;\n\tcorrectResponses: Record<string, unknown>;\n\troleCapabilities: RoleCapabilities;\n\teffectiveDisabled: boolean;\n\tonComponentError?: (interaction: BaseInteractionData, error: unknown) => void;\n}): BlockInteractionMount[] {\n\treturn interactions\n\t\t.filter((interaction) => !isInlineInteractionType(interaction.type))\n\t\t.map((interaction) => {\n\t\t\ttry {\n\t\t\t\tconst stringIdentifier =\n\t\t\t\t\t'stringIdentifier' in interaction && typeof interaction.stringIdentifier === 'string'\n\t\t\t\t\t\t? interaction.stringIdentifier\n\t\t\t\t\t\t: undefined;\n\t\t\t\tconst block: BlockInteractionMount = {\n\t\t\t\t\tplacement: 'block',\n\t\t\t\t\trenderer: 'web-component',\n\t\t\t\t\tinteraction,\n\t\t\t\t\ttagName: source.componentRegistry.getTagName(interaction),\n\t\t\t\t\tkey: interactionKey(interaction),\n\t\t\t\t\tresponse: responses[interaction.responseId] ?? null,\n\t\t\t\t\t...(stringIdentifier\n\t\t\t\t\t\t? { stringResponse: responses[stringIdentifier] ?? null }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\tcorrectResponse: roleCapabilities.canViewCorrectResponses\n\t\t\t\t\t\t? (correctResponses[interaction.responseId] ?? null)\n\t\t\t\t\t\t: null,\n\t\t\t\t\tpnp: source.pnp,\n\t\t\t\t\teliminationTool: source.pnp?.cognitive?.eliminationTool === true,\n\t\t\t\t\tdisabled: effectiveDisabled,\n\t\t\t\t\tcomponentRole: roleCapabilities.canViewCorrectResponses ? 'scorer' : undefined,\n\t\t\t\t};\n\t\t\t\treturn block;\n\t\t\t} catch (error) {\n\t\t\t\tonComponentError?.(interaction, error);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t})\n\t\t.filter((item): item is BlockInteractionMount => item !== null);\n}\n\nexport function interactionKey(interaction: BaseInteractionData): string {\n\tconst anyInteraction = interaction as any;\n\tconst ids =\n\t\tArray.isArray(anyInteraction?.choices) && anyInteraction.choices.length > 0\n\t\t\t? anyInteraction.choices.map((choice: any) => choice?.identifier).filter(Boolean).join(',')\n\t\t\t: '';\n\tconst prompt = typeof anyInteraction?.prompt === 'string' ? anyInteraction.prompt : '';\n\treturn `${interaction.type}|${interaction.responseId}|${ids}|${prompt}`;\n}\n"]}
1
+ {"version":3,"file":"itemPresentationPlan.js","sourceRoot":"","sources":["../../src/presentation/itemPresentationPlan.ts"],"names":[],"mappings":"AACA,OAAO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,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACvF,OAAO,GAAG,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,UAAU,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;AACzE,CAAC","sourcesContent":["import type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';\nimport {\n\tnormalizeHeuristicsConfig,\n\ttype QtiHeuristicsConfig,\n} from '@pie-qti/ims-cp-core';\nimport { parse } from 'node-html-parser';\nimport type { HTMLElement as ParsedHtmlElement } from 'node-html-parser';\nimport type { ComponentRegistry } from '../core/ComponentRegistry.js';\nimport { sanitizeHtml } from '../core/sanitizer.js';\nimport { htmlToString, toTrustedHtml } from '../core/trustedTypes.js';\nimport type { PnpProfile } from '../pnp/types.js';\nimport { getRoleCapabilities, type RoleCapabilities } from '../core/rolePolicy.js';\nimport type {\n\tHtmlContent,\n\tPlayerSecurityConfig,\n\tQTIRole,\n\tRubricBlock,\n} from '../types/index.js';\nimport { processFeedbackInline } from '../components/utils/feedbackUtils.js';\nimport { buildScopedStylesheetCss } from '../components/utils/stylesheetRender.js';\nimport { buildEffectiveStimulusContent, injectStimulusContent } from '../components/utils/stimulusRender.js';\nimport {\n\tcreateInlineRenderPlan,\n\tisInlineInteractionTagName,\n\tisInlineInteractionType,\n} from '../interactions/inline/render-plan.js';\nimport type {\n\tBaseInteractionData,\n\tInlineChoiceInteractionData,\n\tTextEntryInteractionData,\n} from '../interactions/shared/types.js';\n\nexport type ItemPresentationResponseValue = unknown;\nexport type ItemPresentationResponseMap = Record<string, ItemPresentationResponseValue>;\n\n/**\n * Immutable inputs captured from the live item session for one presentation pass.\n *\n * This deliberately contains data rather than a Player-shaped adapter. Presentation\n * cannot reach back into the session midway through a render, and its only live seam\n * is the real component registry used to resolve plugin renderers.\n */\nexport interface ItemPresentationSource {\n\titemBodyHtml: HtmlContent;\n\t/** The content's `xml:lang`, when the item declares one. */\n\tcontentLanguage?: string;\n\tinteractions: readonly BaseInteractionData[];\n\tcorrectResponses: Record<string, unknown>;\n\tcomponentRegistry: ComponentRegistry;\n\tdeliveryContext?: ResolvedItemDeliveryContext;\n\tpnp?: PnpProfile;\n\tsecurity?: PlayerSecurityConfig;\n\t/** Role-filtered, finalized direct rubrics for host placement. */\n\tdirectRubrics?: readonly RubricBlock[];\n}\n\nexport interface CreateItemPresentationOptions {\n\tsource: ItemPresentationSource;\n\tresponses?: ItemPresentationResponseMap;\n\tdisabled?: boolean;\n\trole?: QTIRole;\n\toutcomeValues?: Record<string, unknown>;\n\theuristicsConfig?: QtiHeuristicsConfig;\n\titemBodyScopeSelector?: string;\n\trenderItemBodyRubrics?: boolean;\n\t/** False drops every feedbackInline and feedbackBlock, as test-level showFeedback=\"false\" requires. */\n\tshowFeedback?: boolean;\n\t/** True exposes correct responses whatever the role, as test-level showSolution requires. */\n\tshowSolution?: boolean;\n\tonComponentError?: (interaction: BaseInteractionData, error: unknown) => void;\n}\n\nexport interface BlockInteractionMount {\n\treadonly placement: 'block';\n\treadonly renderer: 'web-component';\n\treadonly interaction: BaseInteractionData;\n\treadonly tagName: string;\n\treadonly key: string;\n\treadonly response: ItemPresentationResponseValue | null;\n\t/** Lexical companion value used by extendedTextInteraction stringIdentifier. */\n\treadonly stringResponse?: ItemPresentationResponseValue | null;\n\treadonly correctResponse: unknown;\n\treadonly pnp: PnpProfile | undefined;\n\treadonly eliminationTool: boolean;\n\treadonly answerMasking: boolean;\n\t/** Label the interaction's answer set as an ARIA group for assistive technology (G-13). */\n\treadonly structuredLabelSupport: boolean;\n\treadonly disabled: boolean;\n\treadonly componentRole: 'scorer' | undefined;\n}\n\nexport type InlineInteractionMount =\n\t| {\n\t\t\treadonly placement: 'inline';\n\t\t\treadonly renderer: 'text-entry';\n\t\t\treadonly interaction: TextEntryInteractionData;\n\t }\n\t| {\n\t\t\treadonly placement: 'inline';\n\t\t\treadonly renderer: 'inline-choice';\n\t\t\treadonly interaction: InlineChoiceInteractionData;\n\t };\n\nexport type ItemInteractionMount = InlineInteractionMount | BlockInteractionMount;\n\ndeclare const finalItemBodyHtmlBrand: unique symbol;\n\n/** HTML that has completed every body transform, sanitation, and Trusted Types finalization. */\nexport type FinalItemBodyHtml = HtmlContent & {\n\treadonly [finalItemBodyHtmlBrand]: true;\n};\n\nexport type ItemPresentationFlowNode =\n\t| { readonly kind: 'html'; readonly html: FinalItemBodyHtml }\n\t| { readonly kind: 'interaction'; readonly mount: ItemInteractionMount };\n\nexport interface ItemPresentation {\n\treadonly capabilities: RoleCapabilities;\n\treadonly disabled: boolean;\n\t/** The language the item body is written in, for its `lang`; undefined when undeclared. */\n\treadonly contentLanguage?: string;\n\treadonly correctResponses: Readonly<Record<string, unknown>>;\n\t/** Direct assessmentItem rubrics that remain outside the item-body flow. */\n\treadonly directRubrics: readonly RubricBlock[];\n\t/** Ordered, render-neutral body flow. Block mounts follow the authored body HTML. */\n\treadonly flow: readonly ItemPresentationFlowNode[];\n\t/** Policy-checked CSS is kept out of the HTML/Trusted Types pipeline. */\n\treadonly scopedCss: string;\n}\n\nexport function createItemPresentation({\n\tsource,\n\tresponses = {},\n\tdisabled = false,\n\trole = 'candidate',\n\toutcomeValues = {},\n\theuristicsConfig,\n\titemBodyScopeSelector = '[data-qti-item-body-scope]',\n\trenderItemBodyRubrics = true,\n\tshowFeedback = true,\n\tshowSolution = false,\n\tonComponentError,\n}: CreateItemPresentationOptions): ItemPresentation {\n\tconst baseCapabilities = getRoleCapabilities(role);\n\tconst roleCapabilities = showSolution\n\t\t? { ...baseCapabilities, canViewCorrectResponses: true }\n\t\t: baseCapabilities;\n\tconst effectiveDisabled = disabled || roleCapabilities.isReadOnly;\n\tconst correctResponses = roleCapabilities.canViewCorrectResponses ? source.correctResponses : {};\n\tconst { html, scopedCss } = buildItemBodyPresentation({\n\t\tsource,\n\t\trole,\n\t\toutcomeValues,\n\t\theuristicsConfig,\n\t\titemBodyScopeSelector,\n\t\trenderItemBodyRubrics,\n\t\tshowFeedback,\n\t});\n\tconst inlineFlow = createInlineRenderPlan(html, source.interactions).map(\n\t\t(segment): ItemPresentationFlowNode => {\n\t\t\tif (segment.type === 'html') {\n\t\t\t\t// Inline planning parses and reserializes the composed body, so sanitation\n\t\t\t\t// belongs after that final string transform and immediately before TT.\n\t\t\t\tconst sanitized = sanitizeHtml(segment.content, { security: source.security });\n\t\t\t\treturn {\n\t\t\t\t\tkind: 'html',\n\t\t\t\t\thtml: finalizeItemBodyHtml(sanitized, source.security),\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (segment.type === 'textEntry') {\n\t\t\t\treturn {\n\t\t\t\t\tkind: 'interaction',\n\t\t\t\t\tmount: {\n\t\t\t\t\t\tplacement: 'inline',\n\t\t\t\t\t\trenderer: 'text-entry',\n\t\t\t\t\t\tinteraction: segment.interaction,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkind: 'interaction',\n\t\t\t\tmount: {\n\t\t\t\t\tplacement: 'inline',\n\t\t\t\t\trenderer: 'inline-choice',\n\t\t\t\t\tinteraction: segment.interaction,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t);\n\tconst blockFlow = createBlockInteractionMounts({\n\t\tinteractions: source.interactions,\n\t\tsource,\n\t\tresponses,\n\t\tcorrectResponses,\n\t\troleCapabilities,\n\t\teffectiveDisabled,\n\t\tonComponentError,\n\t}).map(\n\t\t(mount): ItemPresentationFlowNode => ({\n\t\t\tkind: 'interaction',\n\t\t\tmount,\n\t\t})\n\t);\n\n\treturn freezePresentation({\n\t\tcapabilities: roleCapabilities,\n\t\tdisabled: effectiveDisabled,\n\t\t...(source.contentLanguage ? { contentLanguage: source.contentLanguage } : {}),\n\t\tcorrectResponses,\n\t\tdirectRubrics: source.directRubrics ?? [],\n\t\tflow: [...inlineFlow, ...blockFlow],\n\t\tscopedCss,\n\t});\n}\n\nfunction freezePresentation<T>(value: T): T {\n\tif (!value || typeof value !== 'object' || Object.isFrozen(value)) return value;\n\tconst prototype = Object.getPrototypeOf(value);\n\tif (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) return value;\n\tObject.freeze(value);\n\tfor (const child of Object.values(value as Record<string, unknown>)) {\n\t\tfreezePresentation(child);\n\t}\n\treturn value;\n}\n\nfunction buildItemBodyPresentation({\n\tsource,\n\trole,\n\toutcomeValues,\n\theuristicsConfig,\n\titemBodyScopeSelector,\n\trenderItemBodyRubrics,\n\tshowFeedback,\n}: {\n\tsource: ItemPresentationSource;\n\trole: QTIRole;\n\toutcomeValues: Record<string, unknown>;\n\theuristicsConfig: QtiHeuristicsConfig | undefined;\n\titemBodyScopeSelector: string;\n\trenderItemBodyRubrics: boolean;\n\tshowFeedback: boolean;\n}): { html: string; scopedCss: string } {\n\tlet html = htmlToString(source.itemBodyHtml);\n\tconst scopedCss = buildScopedStylesheetCss(source.deliveryContext, itemBodyScopeSelector);\n\tconst effectiveStimulusContent = buildEffectiveStimulusContent(\n\t\tsource.deliveryContext,\n\t\t(content) => sanitizeHtml(content, { security: source.security })\n\t);\n\n\thtml = injectStimulusContent(html, effectiveStimulusContent);\n\thtml = renderRubricBlocksForRole(html, role, { renderRubrics: renderItemBodyRubrics });\n\n\tconst heuristics = normalizeHeuristicsConfig(heuristicsConfig);\n\thtml = processFeedbackInline(html, {\n\t\toutcomeValues,\n\t\tapplyHeuristics: heuristics.feedbackTextFormatting,\n\t\twrapWithSpan: false,\n\t\thideAll: !showFeedback,\n\t});\n\n\treturn { html: hideBlockInteractionMarkup(html), scopedCss };\n}\n\nfunction finalizeItemBodyHtml(\n\thtml: string,\n\tsecurity: PlayerSecurityConfig | undefined\n): FinalItemBodyHtml {\n\treturn toTrustedHtml(html, security?.trustedTypesPolicyName) as FinalItemBodyHtml;\n}\n\nfunction renderRubricBlocksForRole(\n\thtml: string,\n\trole: QTIRole,\n\t{ renderRubrics }: { renderRubrics: boolean }\n): string {\n\tif (!html || !/rubric-?block/i.test(html)) {\n\t\treturn html;\n\t}\n\n\ttry {\n\t\tconst root = parse(html, { lowerCaseTagName: false, comment: false });\n\t\trenderRubricBlockChildren(root as unknown as ParsedHtmlElement, role, { renderRubrics });\n\t\treturn root.toString();\n\t} catch {\n\t\treturn html;\n\t}\n}\n\nfunction renderRubricBlockChildren(\n\telement: ParsedHtmlElement,\n\trole: QTIRole,\n\t{ renderRubrics }: { renderRubrics: boolean }\n): void {\n\tconst children = [...element.childNodes] as unknown as ParsedHtmlElement[];\n\tfor (const child of children) {\n\t\tconst tagName = child.rawTagName?.toLowerCase();\n\t\tif (\n\t\t\ttagName &&\n\t\t\tisRubricBlockTag(tagName) &&\n\t\t\t(!renderRubrics || !rubricBlockVisibleToRole(child, role))\n\t\t) {\n\t\t\tchild.remove();\n\t\t\tcontinue;\n\t\t}\n\t\tif (child.childNodes?.length) {\n\t\t\trenderRubricBlockChildren(child, role, { renderRubrics });\n\t\t}\n\t\tif (tagName && isRubricBlockTag(tagName)) {\n\t\t\tchild.replaceWith(renderRubricBlockWrapper(child));\n\t\t}\n\t}\n}\n\nfunction isRubricBlockTag(tagName: string): boolean {\n\treturn tagName === 'rubricblock' || tagName === 'qti-rubric-block';\n}\n\nfunction rubricBlockVisibleToRole(element: ParsedHtmlElement, role: QTIRole): boolean {\n\tconst view = element.getAttribute('view')?.trim();\n\tif (!view) {\n\t\treturn true;\n\t}\n\treturn splitRubricView(view).includes(role);\n}\n\nfunction renderRubricBlockWrapper(element: ParsedHtmlElement): string {\n\tconst view = element.getAttribute('view')?.trim();\n\tconst use = element.getAttribute('use')?.trim();\n\tconst attrs = [\n\t\t'class=\"qti-rubric-block\"',\n\t\tview ? `data-qti-rubric-view=\"${escapeHtmlAttribute(view)}\"` : '',\n\t\tuse ? `data-qti-rubric-use=\"${escapeHtmlAttribute(use)}\"` : '',\n\t]\n\t\t.filter(Boolean)\n\t\t.join(' ');\n\treturn `<div ${attrs}>${serializeHtmlChildren(element)}</div>`;\n}\n\nfunction splitRubricView(view: string): string[] {\n\treturn view.split(/[\\s,]+/).filter(Boolean);\n}\n\nfunction serializeHtmlChildren(element: ParsedHtmlElement): string {\n\treturn ([...element.childNodes] as unknown as ParsedHtmlElement[])\n\t\t.map((child) => child.toString())\n\t\t.join('');\n}\n\nfunction escapeHtmlAttribute(value: string): string {\n\treturn value\n\t\t.replace(/&/g, '&amp;')\n\t\t.replace(/\"/g, '&quot;')\n\t\t.replace(/</g, '&lt;')\n\t\t.replace(/>/g, '&gt;');\n}\n\nfunction hideBlockInteractionMarkup(html: string): string {\n\t// positionObjectStage is hidden as a unit: it owns the background object and wraps its\n\t// interactions, all of which the component renders. Matching only the interaction inside it\n\t// would leave the stage's background image visible in the item body as well.\n\treturn html.replace(\n\t\t/<(\\w+Interaction|qti-[\\w-]+-interaction|positionObjectStage|qti-position-object-stage)(\\s[^>]*)?>[\\s\\S]*?<\\/\\1>/gi,\n\t\t(match, tagName) => {\n\t\t\tconst lower = tagName.toLowerCase();\n\t\t\tif (isInlineInteractionTagName(lower)) return match;\n\t\t\treturn `<span class=\"qti-hidden-interaction\">${match}</span>`;\n\t\t}\n\t);\n}\n\nfunction createBlockInteractionMounts({\n\tinteractions,\n\tsource,\n\tresponses,\n\tcorrectResponses,\n\troleCapabilities,\n\teffectiveDisabled,\n\tonComponentError,\n}: {\n\tinteractions: readonly BaseInteractionData[];\n\tsource: ItemPresentationSource;\n\tresponses: ItemPresentationResponseMap;\n\tcorrectResponses: Record<string, unknown>;\n\troleCapabilities: RoleCapabilities;\n\teffectiveDisabled: boolean;\n\tonComponentError?: (interaction: BaseInteractionData, error: unknown) => void;\n}): BlockInteractionMount[] {\n\treturn interactions\n\t\t.filter((interaction) => !isInlineInteractionType(interaction.type))\n\t\t.map((interaction) => {\n\t\t\ttry {\n\t\t\t\tconst stringIdentifier =\n\t\t\t\t\t'stringIdentifier' in interaction && typeof interaction.stringIdentifier === 'string'\n\t\t\t\t\t\t? interaction.stringIdentifier\n\t\t\t\t\t\t: undefined;\n\t\t\t\tconst block: BlockInteractionMount = {\n\t\t\t\t\tplacement: 'block',\n\t\t\t\t\trenderer: 'web-component',\n\t\t\t\t\tinteraction,\n\t\t\t\t\ttagName: source.componentRegistry.getTagName(interaction),\n\t\t\t\t\tkey: interactionKey(interaction),\n\t\t\t\t\tresponse: responses[interaction.responseId] ?? null,\n\t\t\t\t\t...(stringIdentifier\n\t\t\t\t\t\t? { stringResponse: responses[stringIdentifier] ?? null }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\tcorrectResponse: roleCapabilities.canViewCorrectResponses\n\t\t\t\t\t\t? (correctResponses[interaction.responseId] ?? null)\n\t\t\t\t\t\t: null,\n\t\t\t\t\tpnp: source.pnp,\n\t\t\t\t\teliminationTool: source.pnp?.cognitive?.eliminationTool === true,\n\t\t\t\t\tanswerMasking: source.pnp?.cognitive?.answerMasking === true,\n\t\t\t\t\tstructuredLabelSupport: source.pnp?.display?.structuredLabelSupport === true,\n\t\t\t\t\tdisabled: effectiveDisabled,\n\t\t\t\t\tcomponentRole: roleCapabilities.canViewCorrectResponses ? 'scorer' : undefined,\n\t\t\t\t};\n\t\t\t\treturn block;\n\t\t\t} catch (error) {\n\t\t\t\tonComponentError?.(interaction, error);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t})\n\t\t.filter((item): item is BlockInteractionMount => item !== null);\n}\n\nexport function interactionKey(interaction: BaseInteractionData): string {\n\tconst anyInteraction = interaction as any;\n\tconst ids =\n\t\tArray.isArray(anyInteraction?.choices) && anyInteraction.choices.length > 0\n\t\t\t? anyInteraction.choices.map((choice: any) => choice?.identifier).filter(Boolean).join(',')\n\t\t\t: '';\n\tconst prompt = typeof anyInteraction?.prompt === 'string' ? anyInteraction.prompt : '';\n\treturn `${interaction.type}|${interaction.responseId}|${ids}|${prompt}`;\n}\n"]}
package/dist/server.d.ts CHANGED
@@ -70,6 +70,11 @@ export interface ServerScoringResult {
70
70
  maxScore: number;
71
71
  completed: boolean;
72
72
  outcomeValues: Record<string, unknown>;
73
+ /**
74
+ * Whether every declared response matches its correct response; absent when the item has no
75
+ * response or one declares no correct response.
76
+ */
77
+ correct?: boolean;
73
78
  modalFeedback?: ServerModalFeedback[];
74
79
  }
75
80
  /** DOM-free description of an authored processing-fragment include request. */
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACN,8BAA8B,IAAI,wBAAwB,GAE1D,MAAM,oCAAoC,CAAC;AA+M5C,qFAAqF;AACrF,MAAM,UAAU,8BAA8B,CAC7C,MAA4C;IAE5C,MAAM,UAAU,GAAG,wBAAwB,CAAC,MAAwC,CAAC,CAAC;IACtF,OAAO,MAAM,CAAC,MAAM,CAAC;QACpB,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,WAAW,CAAC,UAAwC,EAAE;YACrD,OAAO,IAAI,wBAAwB,CAClC,UAAU,CAAC,WAAW,CAAC,OAAuD,CAAC,CAC/E,CAAC;QACH,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,wBAAwB;IAC7B,YAA6B,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;IAAG,CAAC;IAE7D,KAAK;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAA2B,CAAC;IACtD,CAAC;IAED,QAAQ,CAAC,OAAuC;QAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAqC,CAAC,CAAC;QAChF,OAAO,UAAyC,CAAC;IAClD,CAAC;IAED,SAAS;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAsC,CAAC;IACrE,CAAC;IAED,OAAO;QACN,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;CACD","sourcesContent":["/**\n * DOM-free definition/session interface for backend scoring and persistence.\n *\n * This entrypoint deliberately mirrors the package's primary ownership model without\n * exposing browser presentation, custom-element, PNP, PCI, or catalog capabilities.\n */\nimport {\n\tcreateAssessmentItemDefinition as createDefinitionInternal,\n\ttype AssessmentItemDefinitionConfig,\n} from './core/AssessmentItemDefinition.js';\nimport type {\n\tItemSession as InternalItemSession,\n\tItemSessionCommand as InternalItemSessionCommand,\n} from './core/ItemSession.js';\nimport type {\n\tItemSessionActionResult as InternalItemSessionActionResult,\n\tSerializedItemSessionState as InternalSerializedItemSessionState,\n} from './types/index.js';\n\nexport type ServerQtiRole =\n\t| 'candidate'\n\t| 'scorer'\n\t| 'proctor'\n\t| 'testConstructor'\n\t| 'tutor'\n\t| 'author';\n\nexport type ServerQtiValue =\n\t| { kind: 'null'; baseType?: string; cardinality?: string }\n\t| { kind: 'value'; baseType?: string; cardinality: string; value: unknown }\n\t| { kind: 'invalid'; message: string; baseType?: string; cardinality?: string };\n\nexport type ServerItemLifecycleStatus =\n\t| 'initial'\n\t| 'interacting'\n\t| 'suspended'\n\t| 'closed'\n\t| 'review'\n\t| 'solution'\n\t| 'answer';\n\nexport type ServerCompletionStatus = 'not_attempted' | 'unknown' | 'incomplete' | 'completed';\n\nexport interface ServerSerializedVariable {\n\tidentifier: string;\n\tkind: 'response' | 'outcome' | 'template' | 'context';\n\tbaseType?: string;\n\tcardinality: string;\n\tvalue: unknown;\n\tdefaultValue?: unknown;\n}\n\nexport interface ServerResponseValidationIssue {\n\tresponseId: string;\n\tcode: string;\n\tmessage: string;\n\tseverity: 'error' | 'warning';\n}\n\nexport interface ServerResponseValidationEntry {\n\tresponseId: string;\n\tinteractionType: string;\n\trequired: boolean;\n\tcomplete: boolean;\n\tvalid: boolean;\n\terrors: string[];\n\twarnings: string[];\n}\n\nexport interface ServerResponseValidationResult {\n\tvalid: boolean;\n\tentries: Record<string, ServerResponseValidationEntry>;\n\tissues: ServerResponseValidationIssue[];\n}\n\nexport interface ServerSerializedItemSessionState {\n\titemIdentifier?: string;\n\tsessionGuid: string;\n\tlifecycleStatus: ServerItemLifecycleStatus;\n\tcompletionStatus: ServerCompletionStatus;\n\tnumAttempts: number;\n\tduration: number;\n\tresponseVariables: Record<string, ServerSerializedVariable>;\n\toutcomeVariables: Record<string, ServerSerializedVariable>;\n\ttemplateVariables: Record<string, ServerSerializedVariable>;\n\tcontextVariables: Record<string, ServerSerializedVariable>;\n\tvalidationMessages: ServerResponseValidationIssue[];\n\tsavedAt: string;\n}\n\nexport interface ServerModalFeedback {\n\tidentifier: string;\n\toutcomeIdentifier: string;\n\tshowHide: 'show' | 'hide';\n\tcontent: string;\n\ttitle?: string;\n}\n\nexport interface ServerScoringResult {\n\tscore: number;\n\tmaxScore: number;\n\tcompleted: boolean;\n\toutcomeValues: Record<string, unknown>;\n\tmodalFeedback?: ServerModalFeedback[];\n}\n\n/** DOM-free description of an authored processing-fragment include request. */\nexport interface ServerProcessingFragmentRequest {\n\treadonly href: string;\n\treadonly mode: 'template' | 'response' | 'outcome';\n\treadonly scope: 'item' | 'test';\n\treadonly depth: number;\n}\n\nexport type ServerItemSessionActionCommand =\n\t| { action: 'setResponse'; responseIdentifier: string; value: unknown }\n\t| { action: 'setResponses'; responses: Readonly<Record<string, unknown>> }\n\t| { action: 'suspendAttempt' }\n\t| { action: 'endAttempt'; countAttempt?: boolean; validateResponses?: boolean }\n\t| { action: 'scoreAttempt' }\n\t| { action: 'newTemplate'; resetResponses?: boolean }\n\t| { action: 'submitAttempt'; countAttempt?: boolean };\n\nexport interface ServerItemSessionActionResult {\n\taction: Exclude<\n\t\tServerItemSessionActionCommand,\n\t\t{ action: 'setResponse' } | { action: 'setResponses' }\n\t>['action'];\n\tlifecycleStatus: ServerItemLifecycleStatus;\n\tcompletionStatus: ServerCompletionStatus;\n\tnumAttempts: number;\n\tduration: number;\n\tcompleted: boolean;\n\tsessionState: ServerSerializedItemSessionState;\n\tvalidation?: ServerResponseValidationResult;\n\tscoring?: ServerScoringResult;\n}\n\nexport interface ServerItemSessionView {\n\treadonly revision: number;\n\treadonly itemIdentifier?: string;\n\treadonly role: ServerQtiRole;\n\treadonly lifecycleStatus: ServerItemLifecycleStatus;\n\treadonly completionStatus: ServerCompletionStatus;\n\treadonly numAttempts: number;\n\treadonly duration: number;\n\treadonly adaptive: boolean;\n\treadonly completed: boolean;\n\treadonly canSubmit: boolean;\n\treadonly disposed: boolean;\n\treadonly responses: Readonly<Record<string, unknown>>;\n\treadonly outcomes: Readonly<Record<string, unknown>>;\n\treadonly templates: Readonly<Record<string, unknown>>;\n\treadonly context: Readonly<Record<string, unknown>>;\n}\n\nexport interface ServerItemSessionTransition {\n\treadonly command: ServerItemSessionActionCommand;\n\treadonly previous: ServerItemSessionView;\n\treadonly current: ServerItemSessionView;\n\treadonly result?: ServerItemSessionActionResult;\n}\n\nexport interface ServerOpenItemSessionOptions {\n\treadonly restore?: ServerSerializedItemSessionState;\n\treadonly responses?: Readonly<Record<string, unknown>>;\n\treadonly activate?: boolean;\n}\n\nexport interface ServerItemSession {\n\tstate(): ServerItemSessionView;\n\tdispatch(command: ServerItemSessionActionCommand): ServerItemSessionTransition;\n\tserialize(): ServerSerializedItemSessionState;\n\tdispose(): void;\n}\n\nexport interface ServerAssessmentItemDefinition {\n\treadonly identifier: string;\n\topenSession(options?: ServerOpenItemSessionOptions): ServerItemSession;\n}\n\nexport interface ServerAssessmentItemDefinitionConfig {\n\treadonly itemXml: string;\n\treadonly role?: ServerQtiRole;\n\treadonly seed?: number;\n\treadonly rngFactory?: () => () => number;\n\treadonly customOperators?: Readonly<\n\t\tRecord<\n\t\t\tstring,\n\t\t\t(args: ServerQtiValue[], meta: { class?: string; definition?: string }) => ServerQtiValue\n\t\t>\n\t>;\n\treadonly resolveProcessingFragment?: (\n\t\trequest: ServerProcessingFragmentRequest,\n\t) => string | null | undefined;\n\treadonly processingFragmentLimits?: Readonly<{\n\t\tmaxDepth?: number;\n\t\tmaxCharacters?: number;\n\t}>;\n\treadonly security?: Readonly<{\n\t\tparsingLimits?: Readonly<{\n\t\t\tenabled?: boolean;\n\t\t\trejectDoctype?: boolean;\n\t\t\tmaxItemXmlBytes?: number;\n\t\t\tmaxHtmlBytes?: number;\n\t\t\tmaxHtmlNodes?: number;\n\t\t\tmaxHtmlDepth?: number;\n\t\t}>;\n\t}>;\n\treadonly strictQtiCompliance?: Readonly<{\n\t\tenabled?: boolean;\n\t\trejectUnknownExtensions?: boolean;\n\t\tlogDeviations?: boolean;\n\t}>;\n}\n\n/** Compile immutable QTI source for one or more independent server item sessions. */\nexport function createAssessmentItemDefinition(\n\tconfig: ServerAssessmentItemDefinitionConfig,\n): ServerAssessmentItemDefinition {\n\tconst definition = createDefinitionInternal(config as AssessmentItemDefinitionConfig);\n\treturn Object.freeze({\n\t\tidentifier: definition.identifier,\n\t\topenSession(options: ServerOpenItemSessionOptions = {}) {\n\t\t\treturn new ServerItemSessionAdapter(\n\t\t\t\tdefinition.openSession(options as Parameters<typeof definition.openSession>[0]),\n\t\t\t);\n\t\t},\n\t});\n}\n\nclass ServerItemSessionAdapter implements ServerItemSession {\n\tconstructor(private readonly session: InternalItemSession) {}\n\n\tstate(): ServerItemSessionView {\n\t\treturn this.session.state() as ServerItemSessionView;\n\t}\n\n\tdispatch(command: ServerItemSessionActionCommand): ServerItemSessionTransition {\n\t\tconst transition = this.session.dispatch(command as InternalItemSessionCommand);\n\t\treturn transition as ServerItemSessionTransition;\n\t}\n\n\tserialize(): ServerSerializedItemSessionState {\n\t\treturn this.session.serialize() as ServerSerializedItemSessionState;\n\t}\n\n\tdispose(): void {\n\t\tthis.session.dispose();\n\t}\n}\n\n// Keep the internal result relation checked without exporting DOM-bearing engine types.\ntype _ServerResultCompatibility = InternalItemSessionActionResult extends ServerItemSessionActionResult\n\t? true\n\t: never;\ntype _ServerStateCompatibility = InternalSerializedItemSessionState extends ServerSerializedItemSessionState\n\t? true\n\t: never;\n"]}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACN,8BAA8B,IAAI,wBAAwB,GAE1D,MAAM,oCAAoC,CAAC;AAoN5C,qFAAqF;AACrF,MAAM,UAAU,8BAA8B,CAC7C,MAA4C;IAE5C,MAAM,UAAU,GAAG,wBAAwB,CAAC,MAAwC,CAAC,CAAC;IACtF,OAAO,MAAM,CAAC,MAAM,CAAC;QACpB,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,WAAW,CAAC,UAAwC,EAAE;YACrD,OAAO,IAAI,wBAAwB,CAClC,UAAU,CAAC,WAAW,CAAC,OAAuD,CAAC,CAC/E,CAAC;QACH,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,wBAAwB;IAC7B,YAA6B,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;IAAG,CAAC;IAE7D,KAAK;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAA2B,CAAC;IACtD,CAAC;IAED,QAAQ,CAAC,OAAuC;QAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAqC,CAAC,CAAC;QAChF,OAAO,UAAyC,CAAC;IAClD,CAAC;IAED,SAAS;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAsC,CAAC;IACrE,CAAC;IAED,OAAO;QACN,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;CACD","sourcesContent":["/**\n * DOM-free definition/session interface for backend scoring and persistence.\n *\n * This entrypoint deliberately mirrors the package's primary ownership model without\n * exposing browser presentation, custom-element, PNP, PCI, or catalog capabilities.\n */\nimport {\n\tcreateAssessmentItemDefinition as createDefinitionInternal,\n\ttype AssessmentItemDefinitionConfig,\n} from './core/AssessmentItemDefinition.js';\nimport type {\n\tItemSession as InternalItemSession,\n\tItemSessionCommand as InternalItemSessionCommand,\n} from './core/ItemSession.js';\nimport type {\n\tItemSessionActionResult as InternalItemSessionActionResult,\n\tSerializedItemSessionState as InternalSerializedItemSessionState,\n} from './types/index.js';\n\nexport type ServerQtiRole =\n\t| 'candidate'\n\t| 'scorer'\n\t| 'proctor'\n\t| 'testConstructor'\n\t| 'tutor'\n\t| 'author';\n\nexport type ServerQtiValue =\n\t| { kind: 'null'; baseType?: string; cardinality?: string }\n\t| { kind: 'value'; baseType?: string; cardinality: string; value: unknown }\n\t| { kind: 'invalid'; message: string; baseType?: string; cardinality?: string };\n\nexport type ServerItemLifecycleStatus =\n\t| 'initial'\n\t| 'interacting'\n\t| 'suspended'\n\t| 'closed'\n\t| 'review'\n\t| 'solution'\n\t| 'answer';\n\nexport type ServerCompletionStatus = 'not_attempted' | 'unknown' | 'incomplete' | 'completed';\n\nexport interface ServerSerializedVariable {\n\tidentifier: string;\n\tkind: 'response' | 'outcome' | 'template' | 'context';\n\tbaseType?: string;\n\tcardinality: string;\n\tvalue: unknown;\n\tdefaultValue?: unknown;\n}\n\nexport interface ServerResponseValidationIssue {\n\tresponseId: string;\n\tcode: string;\n\tmessage: string;\n\tseverity: 'error' | 'warning';\n}\n\nexport interface ServerResponseValidationEntry {\n\tresponseId: string;\n\tinteractionType: string;\n\trequired: boolean;\n\tcomplete: boolean;\n\tvalid: boolean;\n\terrors: string[];\n\twarnings: string[];\n}\n\nexport interface ServerResponseValidationResult {\n\tvalid: boolean;\n\tentries: Record<string, ServerResponseValidationEntry>;\n\tissues: ServerResponseValidationIssue[];\n}\n\nexport interface ServerSerializedItemSessionState {\n\titemIdentifier?: string;\n\tsessionGuid: string;\n\tlifecycleStatus: ServerItemLifecycleStatus;\n\tcompletionStatus: ServerCompletionStatus;\n\tnumAttempts: number;\n\tduration: number;\n\tresponseVariables: Record<string, ServerSerializedVariable>;\n\toutcomeVariables: Record<string, ServerSerializedVariable>;\n\ttemplateVariables: Record<string, ServerSerializedVariable>;\n\tcontextVariables: Record<string, ServerSerializedVariable>;\n\tvalidationMessages: ServerResponseValidationIssue[];\n\tsavedAt: string;\n}\n\nexport interface ServerModalFeedback {\n\tidentifier: string;\n\toutcomeIdentifier: string;\n\tshowHide: 'show' | 'hide';\n\tcontent: string;\n\ttitle?: string;\n}\n\nexport interface ServerScoringResult {\n\tscore: number;\n\tmaxScore: number;\n\tcompleted: boolean;\n\toutcomeValues: Record<string, unknown>;\n\t/**\n\t * Whether every declared response matches its correct response; absent when the item has no\n\t * response or one declares no correct response.\n\t */\n\tcorrect?: boolean;\n\tmodalFeedback?: ServerModalFeedback[];\n}\n\n/** DOM-free description of an authored processing-fragment include request. */\nexport interface ServerProcessingFragmentRequest {\n\treadonly href: string;\n\treadonly mode: 'template' | 'response' | 'outcome';\n\treadonly scope: 'item' | 'test';\n\treadonly depth: number;\n}\n\nexport type ServerItemSessionActionCommand =\n\t| { action: 'setResponse'; responseIdentifier: string; value: unknown }\n\t| { action: 'setResponses'; responses: Readonly<Record<string, unknown>> }\n\t| { action: 'suspendAttempt' }\n\t| { action: 'endAttempt'; countAttempt?: boolean; validateResponses?: boolean }\n\t| { action: 'scoreAttempt' }\n\t| { action: 'newTemplate'; resetResponses?: boolean }\n\t| { action: 'submitAttempt'; countAttempt?: boolean };\n\nexport interface ServerItemSessionActionResult {\n\taction: Exclude<\n\t\tServerItemSessionActionCommand,\n\t\t{ action: 'setResponse' } | { action: 'setResponses' }\n\t>['action'];\n\tlifecycleStatus: ServerItemLifecycleStatus;\n\tcompletionStatus: ServerCompletionStatus;\n\tnumAttempts: number;\n\tduration: number;\n\tcompleted: boolean;\n\tsessionState: ServerSerializedItemSessionState;\n\tvalidation?: ServerResponseValidationResult;\n\tscoring?: ServerScoringResult;\n}\n\nexport interface ServerItemSessionView {\n\treadonly revision: number;\n\treadonly itemIdentifier?: string;\n\treadonly role: ServerQtiRole;\n\treadonly lifecycleStatus: ServerItemLifecycleStatus;\n\treadonly completionStatus: ServerCompletionStatus;\n\treadonly numAttempts: number;\n\treadonly duration: number;\n\treadonly adaptive: boolean;\n\treadonly completed: boolean;\n\treadonly canSubmit: boolean;\n\treadonly disposed: boolean;\n\treadonly responses: Readonly<Record<string, unknown>>;\n\treadonly outcomes: Readonly<Record<string, unknown>>;\n\treadonly templates: Readonly<Record<string, unknown>>;\n\treadonly context: Readonly<Record<string, unknown>>;\n}\n\nexport interface ServerItemSessionTransition {\n\treadonly command: ServerItemSessionActionCommand;\n\treadonly previous: ServerItemSessionView;\n\treadonly current: ServerItemSessionView;\n\treadonly result?: ServerItemSessionActionResult;\n}\n\nexport interface ServerOpenItemSessionOptions {\n\treadonly restore?: ServerSerializedItemSessionState;\n\treadonly responses?: Readonly<Record<string, unknown>>;\n\treadonly activate?: boolean;\n}\n\nexport interface ServerItemSession {\n\tstate(): ServerItemSessionView;\n\tdispatch(command: ServerItemSessionActionCommand): ServerItemSessionTransition;\n\tserialize(): ServerSerializedItemSessionState;\n\tdispose(): void;\n}\n\nexport interface ServerAssessmentItemDefinition {\n\treadonly identifier: string;\n\topenSession(options?: ServerOpenItemSessionOptions): ServerItemSession;\n}\n\nexport interface ServerAssessmentItemDefinitionConfig {\n\treadonly itemXml: string;\n\treadonly role?: ServerQtiRole;\n\treadonly seed?: number;\n\treadonly rngFactory?: () => () => number;\n\treadonly customOperators?: Readonly<\n\t\tRecord<\n\t\t\tstring,\n\t\t\t(args: ServerQtiValue[], meta: { class?: string; definition?: string }) => ServerQtiValue\n\t\t>\n\t>;\n\treadonly resolveProcessingFragment?: (\n\t\trequest: ServerProcessingFragmentRequest,\n\t) => string | null | undefined;\n\treadonly processingFragmentLimits?: Readonly<{\n\t\tmaxDepth?: number;\n\t\tmaxCharacters?: number;\n\t}>;\n\treadonly security?: Readonly<{\n\t\tparsingLimits?: Readonly<{\n\t\t\tenabled?: boolean;\n\t\t\trejectDoctype?: boolean;\n\t\t\tmaxItemXmlBytes?: number;\n\t\t\tmaxHtmlBytes?: number;\n\t\t\tmaxHtmlNodes?: number;\n\t\t\tmaxHtmlDepth?: number;\n\t\t}>;\n\t}>;\n\treadonly strictQtiCompliance?: Readonly<{\n\t\tenabled?: boolean;\n\t\trejectUnknownExtensions?: boolean;\n\t\tlogDeviations?: boolean;\n\t}>;\n}\n\n/** Compile immutable QTI source for one or more independent server item sessions. */\nexport function createAssessmentItemDefinition(\n\tconfig: ServerAssessmentItemDefinitionConfig,\n): ServerAssessmentItemDefinition {\n\tconst definition = createDefinitionInternal(config as AssessmentItemDefinitionConfig);\n\treturn Object.freeze({\n\t\tidentifier: definition.identifier,\n\t\topenSession(options: ServerOpenItemSessionOptions = {}) {\n\t\t\treturn new ServerItemSessionAdapter(\n\t\t\t\tdefinition.openSession(options as Parameters<typeof definition.openSession>[0]),\n\t\t\t);\n\t\t},\n\t});\n}\n\nclass ServerItemSessionAdapter implements ServerItemSession {\n\tconstructor(private readonly session: InternalItemSession) {}\n\n\tstate(): ServerItemSessionView {\n\t\treturn this.session.state() as ServerItemSessionView;\n\t}\n\n\tdispatch(command: ServerItemSessionActionCommand): ServerItemSessionTransition {\n\t\tconst transition = this.session.dispatch(command as InternalItemSessionCommand);\n\t\treturn transition as ServerItemSessionTransition;\n\t}\n\n\tserialize(): ServerSerializedItemSessionState {\n\t\treturn this.session.serialize() as ServerSerializedItemSessionState;\n\t}\n\n\tdispose(): void {\n\t\tthis.session.dispose();\n\t}\n}\n\n// Keep the internal result relation checked without exporting DOM-bearing engine types.\ntype _ServerResultCompatibility = InternalItemSessionActionResult extends ServerItemSessionActionResult\n\t? true\n\t: never;\ntype _ServerStateCompatibility = InternalSerializedItemSessionState extends ServerSerializedItemSessionState\n\t? true\n\t: never;\n"]}
@@ -155,6 +155,11 @@ export interface ScoringResult {
155
155
  maxScore: number;
156
156
  completed: boolean;
157
157
  outcomeValues: Record<string, any>;
158
+ /**
159
+ * Whether every declared response matches its correct response; absent when the item has no
160
+ * response or one declares no correct response.
161
+ */
162
+ correct?: boolean;
158
163
  /** Modal feedback elements that should be displayed based on outcome values */
159
164
  modalFeedback?: ModalFeedback[];
160
165
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AA0aH,cAAc,yBAAyB,CAAC","sourcesContent":["/**\n * Core QTI types for the player\n */\n\nimport type {\n\tBaseType as ProcessingBaseType,\n\tCardinality as ProcessingCardinality,\n\tProcessingFragmentResolver,\n\tQtiValue,\n} from '@pie-qti/qti-processing';\nimport type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';\nimport type { PciConfiguration } from '../pci/types.js';\nimport type { ResponseValidationResult } from './responseValidation.js';\n\n/**\n * QTI base type identifier\n * Extensible string type allows custom base types\n */\nexport type VariableBaseType = ProcessingBaseType;\n\n/**\n * QTI cardinality identifier\n * Extensible string type allows custom cardinality values\n */\nexport type VariableCardinality = ProcessingCardinality;\n\nexport interface VariableDeclaration {\n\tidentifier: string;\n\t/** Omitted for record cardinality. */\n\tbaseType?: VariableBaseType;\n\tcardinality: VariableCardinality;\n\tvalue: any;\n\tdefaultValue?: any;\n\tmapping?: Mapping;\n\tareaMapping?: AreaMapping;\n}\n\nexport interface Mapping {\n\tdefaultValue?: number;\n\tlowerBound?: number;\n\tupperBound?: number;\n\t/**\n\t * QTI attribute on <mapping>. When \"false\", string mappings are case-insensitive by default.\n\t * Stored as raw string to match XML attribute values (\"true\"/\"false\").\n\t */\n\tcaseSensitive?: string;\n\tentries: Record<string, MapEntry>;\n}\n\nexport interface MapEntry {\n\tmapKey: string;\n\tmappedValue: number;\n\tcaseSensitive?: string;\n}\n\nexport interface AreaMapping {\n\tdefaultValue?: number;\n\tlowerBound?: number;\n\tupperBound?: number;\n\tentries: AreaMapEntry[];\n}\n\nexport interface AreaMapEntry {\n\tshape: 'circle' | 'rect' | 'poly' | 'ellipse' | 'default';\n\tcoords: string;\n\tmappedValue: number;\n}\n\nexport interface ResponseDeclaration extends VariableDeclaration {\n\tcorrectResponse?: any;\n}\n\nexport interface OutcomeDeclaration extends VariableDeclaration {\n\tinterpretation?: string;\n\tlongInterpretation?: string;\n\tnormalMaximum?: number;\n\tnormalMinimum?: number;\n\tmasteryValue?: number;\n\tviews?: string[];\n}\n\n/** @internal Private engine snapshot shape; use SerializedItemSessionState. */\nexport interface ItemSessionState {\n\t[variableId: string]: any;\n}\n\nexport type ItemLifecycleStatus = 'initial' | 'interacting' | 'suspended' | 'closed' | 'review' | 'solution' | 'answer';\n\nexport type SerializedVariableKind = 'response' | 'outcome' | 'template' | 'context';\n\nexport interface SerializedItemSessionVariable {\n\tidentifier: string;\n\tkind: SerializedVariableKind;\n\t/** Omitted for record cardinality. */\n\tbaseType?: VariableBaseType;\n\tcardinality: VariableCardinality;\n\tvalue: any;\n\tdefaultValue?: any;\n}\n\nexport interface SerializedItemSessionState {\n\titemIdentifier?: string;\n\tsessionGuid: string;\n\tlifecycleStatus: ItemLifecycleStatus;\n\tcompletionStatus: CompletionStatus;\n\tnumAttempts: number;\n\t/**\n\t * Time-on-task in milliseconds, stored as the QTI built-in duration variable value.\n\t */\n\tduration: number;\n\tresponseVariables: Record<string, SerializedItemSessionVariable>;\n\toutcomeVariables: Record<string, SerializedItemSessionVariable>;\n\ttemplateVariables: Record<string, SerializedItemSessionVariable>;\n\tcontextVariables: Record<string, SerializedItemSessionVariable>;\n\tvalidationMessages: ResponseValidationResult['issues'];\n\tsavedAt: string;\n}\n\nexport type ItemSessionAction =\n\t| 'suspendAttempt'\n\t| 'endAttempt'\n\t| 'scoreAttempt'\n\t| 'newTemplate'\n\t| 'submitAttempt';\n\nexport type ItemSessionActionCommand =\n\t| { action: 'suspendAttempt' }\n\t| { action: 'endAttempt'; countAttempt?: boolean; validateResponses?: boolean }\n\t| { action: 'scoreAttempt' }\n\t| { action: 'newTemplate'; resetResponses?: boolean }\n\t| { action: 'submitAttempt'; countAttempt?: boolean };\n\nexport interface ItemSessionActionResult {\n\taction: ItemSessionAction;\n\tlifecycleStatus: ItemLifecycleStatus;\n\tcompletionStatus: CompletionStatus;\n\tnumAttempts: number;\n\tduration: number;\n\tcompleted: boolean;\n\tsessionState: SerializedItemSessionState;\n\tvalidation?: ResponseValidationResult;\n\tscoring?: ScoringResult;\n}\n\n/** @internal Private engine response map. */\nexport interface InteractionResponse {\n\t[responseId: string]: any;\n}\n\n/**\n * Serializable representation of a QTI baseType=\"file\" response.\n * (We cannot store a browser File object in session state / JSON exports.)\n */\nexport interface QTIFileResponse {\n\tname: string;\n\ttype: string;\n\tsize: number;\n\tlastModified: number;\n\t/** Base64 data URL, e.g. data:application/pdf;base64,... */\n\tdataUrl: string;\n\t/**\n\t * Optional ImageData extracted from canvas (for drawing interactions).\n\t * This allows custom operators to analyze drawing content synchronously\n\t * without needing to decode the dataUrl asynchronously.\n\t */\n\timageData?: {\n\t\tdata: Uint8ClampedArray;\n\t\twidth: number;\n\t\theight: number;\n\t};\n}\n\nexport interface ModalFeedback {\n\t/** Unique identifier for this feedback block */\n\tidentifier: string;\n\t/** Outcome variable identifier this feedback is tied to */\n\toutcomeIdentifier: string;\n\t/** When to show: 'show' means display when outcome matches identifier */\n\tshowHide: 'show' | 'hide';\n\t/** HTML content to display */\n\tcontent: HtmlContent;\n\t/** Optional title for the feedback */\n\ttitle?: string;\n}\n\nexport interface ScoringResult {\n\tscore: number;\n\tmaxScore: number;\n\tcompleted: boolean;\n\toutcomeValues: Record<string, any>;\n\t/** Modal feedback elements that should be displayed based on outcome values */\n\tmodalFeedback?: ModalFeedback[];\n}\n\n/**\n * QTI 2.2 completionStatus values for adaptive items\n * - not_attempted: No interaction has occurred yet\n * - unknown: Response exists but hasn't been scored/evaluated\n * - incomplete: Item has been scored but is still active (can submit again)\n * - completed: Item is finished (final state)\n */\nexport type CompletionStatus = 'not_attempted' | 'unknown' | 'incomplete' | 'completed';\n\n/**\n * Extended scoring result for adaptive items with multi-attempt support\n */\nexport interface AdaptiveAttemptResult extends ScoringResult {\n\t/** Number of attempts made so far */\n\tnumAttempts: number;\n\t/** Current completion status of the item */\n\tcompletionStatus: CompletionStatus;\n\t/** Whether the item can accept more submissions */\n\tcanContinue: boolean;\n}\n\n/**\n * QTI role/view actors used for audience filtering (for example rubric/outcome visibility).\n * Runtime interaction behavior (readonly vs editable, correct-answer visibility) is a player\n * policy layered on top of these roles.\n */\nexport type QTIRole = 'candidate' | 'scorer' | 'proctor' | 'testConstructor' | 'tutor' | 'author';\n\nexport type RubricBlockScope = 'direct' | 'itemBody';\n\n/** @internal Private engine rubric query. */\nexport interface RubricBlockOptions {\n\t/**\n\t * `direct` rubrics are assessment-item children and are intended for host placement.\n\t * `itemBody` rubrics are authored in the visible item body flow.\n\t */\n\tscope?: RubricBlockScope | 'all';\n}\n\nexport interface RubricBlock {\n\tview: string[]; // Array of role strings that can see this rubric\n\thtml: HtmlContent; // HTML content of the rubric\n\tscope: RubricBlockScope;\n\tuse?: string;\n}\n\n/**\n * QTI specification compliance configuration.\n * Controls whether the player enforces strict QTI 2.2 spec or allows vendor extensions.\n */\nexport interface QTIComplianceConfig {\n\t/** Enable strict QTI 2.2 compliance mode. Default: false (lenient) */\n\tenabled?: boolean;\n\n\t/** Reject items with unknown or non-standard elements. Default: false */\n\trejectUnknownExtensions?: boolean;\n\n\t/** Log warnings for spec deviations and vendor extensions. Default: true */\n\tlogDeviations?: boolean;\n}\n\n/** @internal Configuration for the private item-session engine. */\nexport interface ItemSessionEngineConfig {\n\titemXml: string;\n\t/**\n\t * QTI 3.0 §6.2 Personal Needs and Preferences profile.\n\t * Color scheme is applied immediately as data-qti-colorscheme on the player root.\n\t * Use player.updatePnp() to change mid-session without re-parsing the item.\n\t */\n\tpnp?: import('../pnp/types.js').PnpProfile;\n\t/**\n\t * Optional shared catalog XML string (QTI 3.0 §6.3).\n\t * Parsed and merged with any catalog embedded in the item XML.\n\t * Item-level catalog entries take precedence over shared entries with the same identifier.\n\t * Deferred: external catalog files from IMS manifest (G-15) are not yet supported.\n\t */\n\tcatalogXml?: string;\n\t/**\n\t * Optional resolved delivery context produced by IMS package/assessment layers.\n\t * This is additive to catalogXml: shared catalog sources are merged first, then\n\t * catalogXml, then item-embedded catalog entries so item-local entries win.\n\t */\n\tdeliveryContext?: ResolvedItemDeliveryContext;\n\trole?: QTIRole;\n\t/** Optional seed for deterministic random operations (e.g. templateProcessing randomInteger) */\n\tseed?: number;\n\t/** Optional RNG override (takes precedence over seed if provided) */\n\trng?: () => number;\n\t/**\n\t * Optional element name mapper for handling different QTI versions.\n\t * Defaults to Qti2xElementNameMapper (primary supported QTI format).\n\t * @since 0.2.0\n\t */\n\telementNameMapper?: any; // Will be ElementNameMapper from @pie-qti/qti-common\n\t/**\n\t * Optional attribute name mapper for handling different QTI versions.\n\t * Defaults to Qti2xAttributeNameMapper (primary supported QTI format).\n\t * @since 0.3.0\n\t */\n\tattributeNameMapper?: any; // Will be AttributeNameMapper from @pie-qti/qti-common\n\t/** Optional web component registry for custom interaction components */\n\tcomponentRegistry?: any; // Will be ComponentRegistry, but avoiding circular dependency\n\t/** Optional extraction registry for custom element extractors */\n\textractionRegistry?: any; // Will be ExtractionRegistry, but avoiding circular dependency\n\t/**\n\t * Optional i18n provider for internationalization.\n\t * If not provided, defaults to DefaultI18nProvider with English messages.\n\t */\n\ti18nProvider?: any; // Will be I18nProvider from @pie-qti/i18n\n\t/**\n\t * Optional registry for executing QTI <customOperator> expressions.\n\t * Keyed by operator `class` (preferred) or `definition` URI.\n\t */\n\tcustomOperators?: Record<string, (args: QtiValue[], meta: { class?: string; definition?: string }) => QtiValue>;\n\t/**\n\t * Host-controlled resolver for xi:include processing fragments.\n\t * The player never fetches an authored href directly; package hosts must resolve\n\t * and containment-check it, then return XML synchronously.\n\t */\n\tresolveProcessingFragment?: ProcessingFragmentResolver;\n\t/** Resource limits applied cumulatively while compiling external processing fragments. */\n\tprocessingFragmentLimits?: {\n\t\t/** Maximum nested xi:include depth. Default: 16. */\n\t\tmaxDepth?: number;\n\t\t/** Maximum cumulative XML characters. Default: 2 MiB. */\n\t\tmaxCharacters?: number;\n\t};\n\t/**\n\t * Portable Custom Interaction runtime configuration.\n\t * A moduleResolver is required before any authored PCI code can execute.\n\t */\n\tpci?: PciConfiguration;\n\t/**\n\t * Security-related controls for untrusted QTI rendered into the host DOM.\n\t * Defaults are conservative for same-DOM embedding.\n\t */\n\tsecurity?: PlayerSecurityConfig;\n\n\t/**\n\t * QTI specification compliance settings.\n\t * Set strictQtiCompliance.enabled = true for strict QTI 2.2 validation.\n\t */\n\tstrictQtiCompliance?: QTIComplianceConfig;\n}\n\nexport interface UrlPolicyConfig {\n\t/**\n\t * Optional base URL used to resolve relative asset URLs (e.g. images/media).\n\t * If omitted, relative URLs are preserved as-is.\n\t */\n\tassetBaseUrl?: string;\n\t/** Allow https: URLs */\n\tallowHttps?: boolean;\n\t/** Allow http: URLs (default false; prefer https) */\n\tallowHttp?: boolean;\n\t/** Allow protocol-relative URLs (e.g. //cdn.example/asset). Default false. */\n\tallowProtocolRelative?: boolean;\n\t/** Allow data:image/* for <img src>. */\n\tallowDataImages?: boolean;\n\t/** Allow data:image/svg+xml (default false) */\n\tallowSvgDataImages?: boolean;\n\t/** Allow blob: URLs for package-resolved images (default false). */\n\tallowBlobImages?: boolean;\n\t/** Allow blob: URLs for package-resolved audio/video media (default false). */\n\tallowBlobMedia?: boolean;\n\t/** Optional allowlist of hostnames for absolute URLs (exact match). */\n\tallowedHosts?: string[];\n}\n\n/**\n * Trusted Types support:\n * - When enabled and supported by the host browser + CSP, HTML-returning APIs may return TrustedHTML instead of string.\n * - When not enabled (default), APIs return plain strings as before.\n */\nexport type TrustedTypesHtml = typeof globalThis extends { TrustedHTML: infer T } ? T : never;\nexport type HtmlContent = string | TrustedTypesHtml;\n\nexport interface PlayerSecurityConfig {\n\t/** URL policy applied to extracted URL fields and HTML attribute URLs */\n\turlPolicy?: UrlPolicyConfig;\n\t/** Allow <object>/<embed> usage (default false) */\n\tallowObjectEmbeds?: boolean;\n\t/** Allow <iframe> usage (default false) */\n\tallowIframes?: boolean;\n\t/**\n\t * Optional parsing/processing guardrails to reduce DoS risk from untrusted QTI.\n\t * Disabled by default for compatibility.\n\t */\n\tparsingLimits?: ParsingLimitsConfig;\n\t/**\n\t * Optional Trusted Types policy name (host-controlled).\n\t * When set, and Trusted Types is available, the player will produce TrustedHTML for HTML injection sinks.\n\t *\n\t * Note: this is only effective when the host enables Trusted Types via CSP.\n\t */\n\ttrustedTypesPolicyName?: string;\n}\n\nexport interface ParsingLimitsConfig {\n\t/**\n\t * Enables parsing limits. When false/undefined, the player behaves exactly as before (compat default).\n\t */\n\tenabled?: boolean;\n\t/**\n\t * Reject any XML containing <!DOCTYPE ...> (case-insensitive) when enabled.\n\t * Helps reduce entity-expansion and other parser edge-case risks.\n\t */\n\trejectDoctype?: boolean;\n\t/**\n\t * Maximum bytes for `itemXml` input (UTF-8). Enforced when enabled.\n\t */\n\tmaxItemXmlBytes?: number;\n\t/**\n\t * Maximum bytes for HTML strings passed to sanitizer (UTF-8). Enforced when enabled.\n\t */\n\tmaxHtmlBytes?: number;\n\t/**\n\t * Maximum number of element nodes sanitized per HTML input. Enforced when enabled.\n\t */\n\tmaxHtmlNodes?: number;\n\t/**\n\t * Maximum element depth sanitized per HTML input. Enforced when enabled.\n\t */\n\tmaxHtmlDepth?: number;\n}\n\nexport interface InteractionContext {\n\tresponseIdentifier: string;\n\tmaxChoices?: number;\n\tminChoices?: number;\n\tshuffle?: boolean;\n\torientation?: 'horizontal' | 'vertical';\n}\n\nexport * from './responseValidation.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAybH,cAAc,yBAAyB,CAAC","sourcesContent":["/**\n * Core QTI types for the player\n */\n\nimport type {\n\tBaseType as ProcessingBaseType,\n\tCardinality as ProcessingCardinality,\n\tProcessingFragmentResolver,\n\tQtiValue,\n} from '@pie-qti/qti-processing';\nimport type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';\nimport type { PciConfiguration } from '../pci/types.js';\nimport type { ResponseValidationResult } from './responseValidation.js';\n\n/**\n * QTI base type identifier\n * Extensible string type allows custom base types\n */\nexport type VariableBaseType = ProcessingBaseType;\n\n/**\n * QTI cardinality identifier\n * Extensible string type allows custom cardinality values\n */\nexport type VariableCardinality = ProcessingCardinality;\n\nexport interface VariableDeclaration {\n\tidentifier: string;\n\t/** Omitted for record cardinality. */\n\tbaseType?: VariableBaseType;\n\tcardinality: VariableCardinality;\n\tvalue: any;\n\tdefaultValue?: any;\n\tmapping?: Mapping;\n\tareaMapping?: AreaMapping;\n}\n\nexport interface Mapping {\n\tdefaultValue?: number;\n\tlowerBound?: number;\n\tupperBound?: number;\n\t/**\n\t * QTI attribute on <mapping>. When \"false\", string mappings are case-insensitive by default.\n\t * Stored as raw string to match XML attribute values (\"true\"/\"false\").\n\t */\n\tcaseSensitive?: string;\n\tentries: Record<string, MapEntry>;\n}\n\nexport interface MapEntry {\n\tmapKey: string;\n\tmappedValue: number;\n\tcaseSensitive?: string;\n}\n\nexport interface AreaMapping {\n\tdefaultValue?: number;\n\tlowerBound?: number;\n\tupperBound?: number;\n\tentries: AreaMapEntry[];\n}\n\nexport interface AreaMapEntry {\n\tshape: 'circle' | 'rect' | 'poly' | 'ellipse' | 'default';\n\tcoords: string;\n\tmappedValue: number;\n}\n\nexport interface ResponseDeclaration extends VariableDeclaration {\n\tcorrectResponse?: any;\n}\n\nexport interface OutcomeDeclaration extends VariableDeclaration {\n\tinterpretation?: string;\n\tlongInterpretation?: string;\n\tnormalMaximum?: number;\n\tnormalMinimum?: number;\n\tmasteryValue?: number;\n\tviews?: string[];\n}\n\n/** @internal Private engine snapshot shape; use SerializedItemSessionState. */\nexport interface ItemSessionState {\n\t[variableId: string]: any;\n}\n\nexport type ItemLifecycleStatus = 'initial' | 'interacting' | 'suspended' | 'closed' | 'review' | 'solution' | 'answer';\n\nexport type SerializedVariableKind = 'response' | 'outcome' | 'template' | 'context';\n\nexport interface SerializedItemSessionVariable {\n\tidentifier: string;\n\tkind: SerializedVariableKind;\n\t/** Omitted for record cardinality. */\n\tbaseType?: VariableBaseType;\n\tcardinality: VariableCardinality;\n\tvalue: any;\n\tdefaultValue?: any;\n}\n\nexport interface SerializedItemSessionState {\n\titemIdentifier?: string;\n\tsessionGuid: string;\n\tlifecycleStatus: ItemLifecycleStatus;\n\tcompletionStatus: CompletionStatus;\n\tnumAttempts: number;\n\t/**\n\t * Time-on-task in milliseconds, stored as the QTI built-in duration variable value.\n\t */\n\tduration: number;\n\tresponseVariables: Record<string, SerializedItemSessionVariable>;\n\toutcomeVariables: Record<string, SerializedItemSessionVariable>;\n\ttemplateVariables: Record<string, SerializedItemSessionVariable>;\n\tcontextVariables: Record<string, SerializedItemSessionVariable>;\n\tvalidationMessages: ResponseValidationResult['issues'];\n\tsavedAt: string;\n}\n\nexport type ItemSessionAction =\n\t| 'suspendAttempt'\n\t| 'endAttempt'\n\t| 'scoreAttempt'\n\t| 'newTemplate'\n\t| 'submitAttempt';\n\nexport type ItemSessionActionCommand =\n\t| { action: 'suspendAttempt' }\n\t| { action: 'endAttempt'; countAttempt?: boolean; validateResponses?: boolean }\n\t| { action: 'scoreAttempt' }\n\t| { action: 'newTemplate'; resetResponses?: boolean }\n\t| { action: 'submitAttempt'; countAttempt?: boolean };\n\nexport interface ItemSessionActionResult {\n\taction: ItemSessionAction;\n\tlifecycleStatus: ItemLifecycleStatus;\n\tcompletionStatus: CompletionStatus;\n\tnumAttempts: number;\n\tduration: number;\n\tcompleted: boolean;\n\tsessionState: SerializedItemSessionState;\n\tvalidation?: ResponseValidationResult;\n\tscoring?: ScoringResult;\n}\n\n/** @internal Private engine response map. */\nexport interface InteractionResponse {\n\t[responseId: string]: any;\n}\n\n/**\n * Serializable representation of a QTI baseType=\"file\" response.\n * (We cannot store a browser File object in session state / JSON exports.)\n */\nexport interface QTIFileResponse {\n\tname: string;\n\ttype: string;\n\tsize: number;\n\tlastModified: number;\n\t/** Base64 data URL, e.g. data:application/pdf;base64,... */\n\tdataUrl: string;\n\t/**\n\t * Optional ImageData extracted from canvas (for drawing interactions).\n\t * This allows custom operators to analyze drawing content synchronously\n\t * without needing to decode the dataUrl asynchronously.\n\t */\n\timageData?: {\n\t\tdata: Uint8ClampedArray;\n\t\twidth: number;\n\t\theight: number;\n\t};\n}\n\nexport interface ModalFeedback {\n\t/** Unique identifier for this feedback block */\n\tidentifier: string;\n\t/** Outcome variable identifier this feedback is tied to */\n\toutcomeIdentifier: string;\n\t/** When to show: 'show' means display when outcome matches identifier */\n\tshowHide: 'show' | 'hide';\n\t/** HTML content to display */\n\tcontent: HtmlContent;\n\t/** Optional title for the feedback */\n\ttitle?: string;\n}\n\nexport interface ScoringResult {\n\tscore: number;\n\tmaxScore: number;\n\tcompleted: boolean;\n\toutcomeValues: Record<string, any>;\n\t/**\n\t * Whether every declared response matches its correct response; absent when the item has no\n\t * response or one declares no correct response.\n\t */\n\tcorrect?: boolean;\n\t/** Modal feedback elements that should be displayed based on outcome values */\n\tmodalFeedback?: ModalFeedback[];\n}\n\n/**\n * QTI 2.2 completionStatus values for adaptive items\n * - not_attempted: No interaction has occurred yet\n * - unknown: Response exists but hasn't been scored/evaluated\n * - incomplete: Item has been scored but is still active (can submit again)\n * - completed: Item is finished (final state)\n */\nexport type CompletionStatus = 'not_attempted' | 'unknown' | 'incomplete' | 'completed';\n\n/**\n * Extended scoring result for adaptive items with multi-attempt support\n */\nexport interface AdaptiveAttemptResult extends ScoringResult {\n\t/** Number of attempts made so far */\n\tnumAttempts: number;\n\t/** Current completion status of the item */\n\tcompletionStatus: CompletionStatus;\n\t/** Whether the item can accept more submissions */\n\tcanContinue: boolean;\n}\n\n/**\n * QTI role/view actors used for audience filtering (for example rubric/outcome visibility).\n * Runtime interaction behavior (readonly vs editable, correct-answer visibility) is a player\n * policy layered on top of these roles.\n */\nexport type QTIRole = 'candidate' | 'scorer' | 'proctor' | 'testConstructor' | 'tutor' | 'author';\n\nexport type RubricBlockScope = 'direct' | 'itemBody';\n\n/** @internal Private engine rubric query. */\nexport interface RubricBlockOptions {\n\t/**\n\t * `direct` rubrics are assessment-item children and are intended for host placement.\n\t * `itemBody` rubrics are authored in the visible item body flow.\n\t */\n\tscope?: RubricBlockScope | 'all';\n}\n\nexport interface RubricBlock {\n\tview: string[]; // Array of role strings that can see this rubric\n\thtml: HtmlContent; // HTML content of the rubric\n\tscope: RubricBlockScope;\n\tuse?: string;\n}\n\n/**\n * QTI specification compliance configuration.\n * Controls whether the player enforces strict QTI 2.2 spec or allows vendor extensions.\n */\nexport interface QTIComplianceConfig {\n\t/** Enable strict QTI 2.2 compliance mode. Default: false (lenient) */\n\tenabled?: boolean;\n\n\t/** Reject items with unknown or non-standard elements. Default: false */\n\trejectUnknownExtensions?: boolean;\n\n\t/** Log warnings for spec deviations and vendor extensions. Default: true */\n\tlogDeviations?: boolean;\n}\n\n/** @internal Configuration for the private item-session engine. */\nexport interface ItemSessionEngineConfig {\n\titemXml: string;\n\t/**\n\t * QTI 3.0 §6.2 Personal Needs and Preferences profile.\n\t * Display needs are applied as attributes and custom properties on the player root.\n\t * Use player.updatePnp() to change mid-session without re-parsing the item.\n\t */\n\tpnp?: import('../pnp/types.js').PnpProfile;\n\t/**\n\t * Optional shared catalog XML string (QTI 3.0 §6.3).\n\t * Parsed and merged with any catalog embedded in the item XML.\n\t * Item-level catalog entries take precedence over shared entries with the same identifier.\n\t * Deferred: external catalog files from IMS manifest (G-15) are not yet supported.\n\t */\n\tcatalogXml?: string;\n\t/**\n\t * Optional resolved delivery context produced by IMS package/assessment layers.\n\t * This is additive to catalogXml: shared catalog sources are merged first, then\n\t * catalogXml, then item-embedded catalog entries so item-local entries win.\n\t */\n\tdeliveryContext?: ResolvedItemDeliveryContext;\n\trole?: QTIRole;\n\t/**\n\t * Values for the item's context variables, set before template processing: `QTI_CONTEXT`, a\n\t * record, and any declared by `contextDeclaration` (`qti-context-declaration`).\n\t */\n\tcontextVariables?: Readonly<Record<string, unknown>>;\n\t/**\n\t * Default values for template variables, set before template processing and kept by\n\t * `newTemplate`, as an assessmentItemRef's `templateDefault` requires.\n\t */\n\ttemplateDefaults?: Readonly<Record<string, unknown>>;\n\t/** Optional seed for deterministic random operations (e.g. templateProcessing randomInteger) */\n\tseed?: number;\n\t/** Optional RNG override (takes precedence over seed if provided) */\n\trng?: () => number;\n\t/**\n\t * Optional element name mapper for handling different QTI versions.\n\t * Defaults to Qti2xElementNameMapper (primary supported QTI format).\n\t * @since 0.2.0\n\t */\n\telementNameMapper?: any; // Will be ElementNameMapper from @pie-qti/qti-common\n\t/**\n\t * Optional attribute name mapper for handling different QTI versions.\n\t * Defaults to Qti2xAttributeNameMapper (primary supported QTI format).\n\t * @since 0.3.0\n\t */\n\tattributeNameMapper?: any; // Will be AttributeNameMapper from @pie-qti/qti-common\n\t/** Optional web component registry for custom interaction components */\n\tcomponentRegistry?: any; // Will be ComponentRegistry, but avoiding circular dependency\n\t/** Optional extraction registry for custom element extractors */\n\textractionRegistry?: any; // Will be ExtractionRegistry, but avoiding circular dependency\n\t/**\n\t * Optional i18n provider for internationalization.\n\t * If not provided, defaults to DefaultI18nProvider with English messages.\n\t */\n\ti18nProvider?: any; // Will be I18nProvider from @pie-qti/i18n\n\t/**\n\t * Optional registry for executing QTI <customOperator> expressions.\n\t * Keyed by operator `class` (preferred) or `definition` URI.\n\t */\n\tcustomOperators?: Record<string, (args: QtiValue[], meta: { class?: string; definition?: string }) => QtiValue>;\n\t/**\n\t * Host-controlled resolver for xi:include processing fragments.\n\t * The player never fetches an authored href directly; package hosts must resolve\n\t * and containment-check it, then return XML synchronously.\n\t */\n\tresolveProcessingFragment?: ProcessingFragmentResolver;\n\t/** Resource limits applied cumulatively while compiling external processing fragments. */\n\tprocessingFragmentLimits?: {\n\t\t/** Maximum nested xi:include depth. Default: 16. */\n\t\tmaxDepth?: number;\n\t\t/** Maximum cumulative XML characters. Default: 2 MiB. */\n\t\tmaxCharacters?: number;\n\t};\n\t/**\n\t * Portable Custom Interaction runtime configuration.\n\t * A moduleResolver is required before any authored PCI code can execute.\n\t */\n\tpci?: PciConfiguration;\n\t/**\n\t * Security-related controls for untrusted QTI rendered into the host DOM.\n\t * Defaults are conservative for same-DOM embedding.\n\t */\n\tsecurity?: PlayerSecurityConfig;\n\n\t/**\n\t * QTI specification compliance settings.\n\t * Set strictQtiCompliance.enabled = true for strict QTI 2.2 validation.\n\t */\n\tstrictQtiCompliance?: QTIComplianceConfig;\n}\n\nexport interface UrlPolicyConfig {\n\t/**\n\t * Optional base URL used to resolve relative asset URLs (e.g. images/media).\n\t * If omitted, relative URLs are preserved as-is.\n\t */\n\tassetBaseUrl?: string;\n\t/** Allow https: URLs */\n\tallowHttps?: boolean;\n\t/** Allow http: URLs (default false; prefer https) */\n\tallowHttp?: boolean;\n\t/** Allow protocol-relative URLs (e.g. //cdn.example/asset). Default false. */\n\tallowProtocolRelative?: boolean;\n\t/** Allow data:image/* for <img src>. */\n\tallowDataImages?: boolean;\n\t/** Allow data:image/svg+xml (default false) */\n\tallowSvgDataImages?: boolean;\n\t/** Allow blob: URLs for package-resolved images (default false). */\n\tallowBlobImages?: boolean;\n\t/** Allow blob: URLs for package-resolved audio/video media (default false). */\n\tallowBlobMedia?: boolean;\n\t/** Optional allowlist of hostnames for absolute URLs (exact match). */\n\tallowedHosts?: string[];\n}\n\n/**\n * Trusted Types support:\n * - When enabled and supported by the host browser + CSP, HTML-returning APIs may return TrustedHTML instead of string.\n * - When not enabled (default), APIs return plain strings as before.\n */\nexport type TrustedTypesHtml = typeof globalThis extends { TrustedHTML: infer T } ? T : never;\nexport type HtmlContent = string | TrustedTypesHtml;\n\nexport interface PlayerSecurityConfig {\n\t/** URL policy applied to extracted URL fields and HTML attribute URLs */\n\turlPolicy?: UrlPolicyConfig;\n\t/** Allow <object>/<embed> usage (default false) */\n\tallowObjectEmbeds?: boolean;\n\t/** Allow <iframe> usage (default false) */\n\tallowIframes?: boolean;\n\t/**\n\t * Optional parsing/processing guardrails to reduce DoS risk from untrusted QTI.\n\t * Disabled by default for compatibility.\n\t */\n\tparsingLimits?: ParsingLimitsConfig;\n\t/**\n\t * Optional Trusted Types policy name (host-controlled).\n\t * When set, and Trusted Types is available, the player will produce TrustedHTML for HTML injection sinks.\n\t *\n\t * Note: this is only effective when the host enables Trusted Types via CSP.\n\t */\n\ttrustedTypesPolicyName?: string;\n}\n\nexport interface ParsingLimitsConfig {\n\t/**\n\t * Enables parsing limits. When false/undefined, the player behaves exactly as before (compat default).\n\t */\n\tenabled?: boolean;\n\t/**\n\t * Reject any XML containing <!DOCTYPE ...> (case-insensitive) when enabled.\n\t * Helps reduce entity-expansion and other parser edge-case risks.\n\t */\n\trejectDoctype?: boolean;\n\t/**\n\t * Maximum bytes for `itemXml` input (UTF-8). Enforced when enabled.\n\t */\n\tmaxItemXmlBytes?: number;\n\t/**\n\t * Maximum bytes for HTML strings passed to sanitizer (UTF-8). Enforced when enabled.\n\t */\n\tmaxHtmlBytes?: number;\n\t/**\n\t * Maximum number of element nodes sanitized per HTML input. Enforced when enabled.\n\t */\n\tmaxHtmlNodes?: number;\n\t/**\n\t * Maximum element depth sanitized per HTML input. Enforced when enabled.\n\t */\n\tmaxHtmlDepth?: number;\n}\n\nexport interface InteractionContext {\n\tresponseIdentifier: string;\n\tmaxChoices?: number;\n\tminChoices?: number;\n\tshuffle?: boolean;\n\torientation?: 'horizontal' | 'vertical';\n}\n\nexport * from './responseValidation.js';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-qti/item-player",
3
- "version": "0.1.27",
3
+ "version": "1.0.0-beta.0",
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",
@@ -27,14 +27,14 @@
27
27
  ],
28
28
  "license": "MIT",
29
29
  "dependencies": {
30
- "@pie-qti/ims-cp-core": "0.1.27",
31
- "@pie-qti/qti-common": "0.1.27",
32
- "@pie-qti/qti-processing": "0.1.27",
30
+ "@pie-qti/ims-cp-core": "1.0.0-beta.0",
31
+ "@pie-qti/qti-common": "1.0.0-beta.0",
32
+ "@pie-qti/qti-processing": "1.0.0-beta.0",
33
33
  "mathlive": "^0.110.0",
34
34
  "node-html-parser": "^9.0.4"
35
35
  },
36
36
  "peerDependencies": {
37
- "@pie-qti/i18n": "0.1.27"
37
+ "@pie-qti/i18n": "1.0.0-beta.0"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@pie-qti/i18n": {
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@biomejs/biome": "^2.5.15",
46
- "@pie-qti/i18n": "0.1.27",
46
+ "@pie-qti/i18n": "1.0.0-beta.0",
47
47
  "@sveltejs/vite-plugin-svelte": "^7.3.0",
48
48
  "@types/node": "^26.6.4",
49
49
  "svelte": "^5.57.1",