@pie-qti/item-player 1.0.0-beta.4 → 1.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -6
- package/dist/catalog/applyGlossaryTriggers.js +14 -2
- package/dist/catalog/applyGlossaryTriggers.js.map +1 -1
- package/dist/catalog/catalogExtractor.js +2 -4
- package/dist/catalog/catalogExtractor.js.map +1 -1
- package/dist/catalog/sessionCatalog.d.ts +46 -0
- package/dist/catalog/sessionCatalog.js +87 -0
- package/dist/catalog/sessionCatalog.js.map +1 -0
- package/dist/components/utils/endAttempt.d.ts +16 -0
- package/dist/components/utils/endAttempt.js +28 -0
- package/dist/components/utils/endAttempt.js.map +1 -0
- package/dist/components/utils/focus.d.ts +19 -0
- package/dist/components/utils/focus.js +67 -0
- package/dist/components/utils/focus.js.map +1 -0
- package/dist/components/utils/itemBodyRenderer.d.ts +44 -0
- package/dist/components/utils/itemBodyRenderer.js +177 -0
- package/dist/components/utils/itemBodyRenderer.js.map +1 -0
- package/dist/components/utils/sentenceContext.d.ts +6 -0
- package/dist/components/utils/sentenceContext.js +16 -0
- package/dist/components/utils/sentenceContext.js.map +1 -0
- package/dist/core/AssessmentItemDefinition.d.ts +20 -1
- package/dist/core/AssessmentItemDefinition.js +12 -31
- package/dist/core/AssessmentItemDefinition.js.map +1 -1
- package/dist/core/ComponentRegistry.d.ts +92 -0
- package/dist/core/ComponentRegistry.js +7 -1
- package/dist/core/ComponentRegistry.js.map +1 -1
- package/dist/core/ItemSession.d.ts +18 -1
- package/dist/core/ItemSession.js +79 -41
- package/dist/core/ItemSession.js.map +1 -1
- package/dist/core/Player.d.ts +118 -141
- package/dist/core/Player.js +390 -1233
- package/dist/core/Player.js.map +1 -1
- package/dist/core/compliance.d.ts +72 -0
- package/dist/core/compliance.js +147 -0
- package/dist/core/compliance.js.map +1 -0
- package/dist/core/declarations/declarationBuilder.d.ts +29 -0
- package/dist/core/declarations/declarationBuilder.js +284 -0
- package/dist/core/declarations/declarationBuilder.js.map +1 -0
- package/dist/core/declarations/declarationValues.d.ts +11 -0
- package/dist/core/declarations/declarationValues.js +168 -0
- package/dist/core/declarations/declarationValues.js.map +1 -0
- package/dist/core/matchGroups.d.ts +36 -0
- package/dist/core/matchGroups.js +100 -0
- package/dist/core/matchGroups.js.map +1 -0
- package/dist/core/nameMappers.d.ts +35 -0
- package/dist/core/nameMappers.js +47 -0
- package/dist/core/nameMappers.js.map +1 -0
- package/dist/core/parsingLimits.d.ts +4 -0
- package/dist/core/parsingLimits.js +5 -2
- package/dist/core/parsingLimits.js.map +1 -1
- package/dist/core/processing/responseProcessing.d.ts +88 -0
- package/dist/core/processing/responseProcessing.js +317 -0
- package/dist/core/processing/responseProcessing.js.map +1 -0
- package/dist/core/processing/responseValidation.d.ts +55 -0
- package/dist/core/processing/responseValidation.js +335 -0
- package/dist/core/processing/responseValidation.js.map +1 -0
- package/dist/core/rendering/contentPass.d.ts +31 -0
- package/dist/core/rendering/contentPass.js +152 -0
- package/dist/core/rendering/contentPass.js.map +1 -0
- package/dist/core/rendering/htmlRender.d.ts +21 -0
- package/dist/core/rendering/htmlRender.js +56 -0
- package/dist/core/rendering/htmlRender.js.map +1 -0
- package/dist/core/responseProcessingTemplates.d.ts +23 -0
- package/dist/core/responseProcessingTemplates.js +45 -0
- package/dist/core/responseProcessingTemplates.js.map +1 -0
- package/dist/core/rolePolicy.d.ts +5 -0
- package/dist/core/rolePolicy.js +21 -0
- package/dist/core/rolePolicy.js.map +1 -1
- package/dist/core/sanitizer.js +8 -14
- package/dist/core/sanitizer.js.map +1 -1
- package/dist/core/serialization/sessionState.d.ts +56 -0
- package/dist/core/serialization/sessionState.js +139 -0
- package/dist/core/serialization/sessionState.js.map +1 -0
- package/dist/core/serialization/valueForms.d.ts +32 -0
- package/dist/core/serialization/valueForms.js +112 -0
- package/dist/core/serialization/valueForms.js.map +1 -0
- package/dist/document/AssessmentItemDocument.d.ts +27 -1
- package/dist/document/AssessmentItemDocument.js +67 -31
- package/dist/document/AssessmentItemDocument.js.map +1 -1
- package/dist/element-class-BUFpUrJP.js +3792 -0
- package/dist/element-class-BUFpUrJP.js.map +1 -0
- package/dist/element-class.d.ts +34 -1
- package/dist/element-class.js +1 -1
- package/dist/element.js +2 -3
- package/dist/extraction/ExtractionRegistry.js +6 -12
- package/dist/extraction/ExtractionRegistry.js.map +1 -1
- package/dist/extraction/createContext.d.ts +2 -2
- package/dist/extraction/createContext.js.map +1 -1
- package/dist/extraction/index.d.ts +2 -2
- package/dist/extraction/index.js +1 -1
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/interactionCoverage.d.ts +31 -0
- package/dist/extraction/interactionCoverage.js +40 -0
- package/dist/extraction/interactionCoverage.js.map +1 -0
- package/dist/extraction/interactionExtractionPipeline.js +5 -10
- package/dist/extraction/interactionExtractionPipeline.js.map +1 -1
- package/dist/extraction/interactionSecurity.js +1 -28
- package/dist/extraction/interactionSecurity.js.map +1 -1
- package/dist/extraction/mergeDeliveryFields.d.ts +13 -0
- package/dist/extraction/mergeDeliveryFields.js +17 -0
- package/dist/extraction/mergeDeliveryFields.js.map +1 -0
- package/dist/extraction/responseIdentifier.d.ts +19 -0
- package/dist/extraction/responseIdentifier.js +29 -0
- package/dist/extraction/responseIdentifier.js.map +1 -0
- package/dist/extraction/types.d.ts +11 -18
- package/dist/extraction/types.js +0 -12
- package/dist/extraction/types.js.map +1 -1
- package/dist/extraction/utils.d.ts +14 -0
- package/dist/extraction/utils.js +35 -5
- package/dist/extraction/utils.js.map +1 -1
- package/dist/index.d.ts +16 -10
- package/dist/index.js +19 -8
- package/dist/index.js.map +1 -1
- package/dist/interactions/associate/extractor.d.ts +1 -0
- package/dist/interactions/associate/extractor.js +10 -12
- package/dist/interactions/associate/extractor.js.map +1 -1
- package/dist/interactions/choice/extractor.js +6 -13
- package/dist/interactions/choice/extractor.js.map +1 -1
- package/dist/interactions/drawing/extractor.d.ts +6 -0
- package/dist/interactions/drawing/extractor.js +30 -9
- package/dist/interactions/drawing/extractor.js.map +1 -1
- package/dist/interactions/end-attempt/extractor.js +2 -1
- package/dist/interactions/end-attempt/extractor.js.map +1 -1
- package/dist/interactions/extended-text/extractor.d.ts +6 -1
- package/dist/interactions/extended-text/extractor.js +10 -5
- package/dist/interactions/extended-text/extractor.js.map +1 -1
- package/dist/interactions/extended-text/response.js +18 -18
- package/dist/interactions/extended-text/response.js.map +1 -1
- package/dist/interactions/gap-match/extractor.d.ts +40 -2
- package/dist/interactions/gap-match/extractor.js +197 -39
- package/dist/interactions/gap-match/extractor.js.map +1 -1
- package/dist/interactions/graphic-associate/extractor.d.ts +11 -0
- package/dist/interactions/graphic-associate/extractor.js +35 -24
- package/dist/interactions/graphic-associate/extractor.js.map +1 -1
- package/dist/interactions/graphic-gap-match/extractor.d.ts +21 -0
- package/dist/interactions/graphic-gap-match/extractor.js +79 -43
- package/dist/interactions/graphic-gap-match/extractor.js.map +1 -1
- package/dist/interactions/graphic-order/extractor.d.ts +15 -0
- package/dist/interactions/graphic-order/extractor.js +39 -24
- package/dist/interactions/graphic-order/extractor.js.map +1 -1
- package/dist/interactions/hotspot/extractor.d.ts +6 -0
- package/dist/interactions/hotspot/extractor.js +31 -16
- package/dist/interactions/hotspot/extractor.js.map +1 -1
- package/dist/interactions/hottext/extractor.js +2 -12
- package/dist/interactions/hottext/extractor.js.map +1 -1
- package/dist/interactions/inline/accessibleName.d.ts +29 -0
- package/dist/interactions/inline/accessibleName.js +35 -0
- package/dist/interactions/inline/accessibleName.js.map +1 -0
- package/dist/interactions/inline/render-plan.d.ts +5 -14
- package/dist/interactions/inline/render-plan.js +5 -56
- package/dist/interactions/inline/render-plan.js.map +1 -1
- package/dist/interactions/inline-choice/extractor.d.ts +4 -0
- package/dist/interactions/inline-choice/extractor.js +13 -12
- package/dist/interactions/inline-choice/extractor.js.map +1 -1
- package/dist/interactions/match/extractor.d.ts +2 -0
- package/dist/interactions/match/extractor.js +14 -28
- package/dist/interactions/match/extractor.js.map +1 -1
- package/dist/interactions/media/extractor.d.ts +5 -11
- package/dist/interactions/media/extractor.js +100 -36
- package/dist/interactions/media/extractor.js.map +1 -1
- package/dist/interactions/modules.js +8 -2
- package/dist/interactions/modules.js.map +1 -1
- package/dist/interactions/order/extractor.d.ts +2 -0
- package/dist/interactions/order/extractor.js +8 -12
- package/dist/interactions/order/extractor.js.map +1 -1
- package/dist/interactions/order/limits.d.ts +29 -0
- package/dist/interactions/order/limits.js +28 -0
- package/dist/interactions/order/limits.js.map +1 -0
- package/dist/interactions/portable-custom/extractor.js +18 -14
- package/dist/interactions/portable-custom/extractor.js.map +1 -1
- package/dist/interactions/position-object/extractor.d.ts +18 -1
- package/dist/interactions/position-object/extractor.js +81 -22
- package/dist/interactions/position-object/extractor.js.map +1 -1
- package/dist/interactions/select-point/extractor.d.ts +6 -0
- package/dist/interactions/select-point/extractor.js +31 -19
- package/dist/interactions/select-point/extractor.js.map +1 -1
- package/dist/interactions/shared/imageAlt.d.ts +54 -0
- package/dist/interactions/shared/imageAlt.js +84 -0
- package/dist/interactions/shared/imageAlt.js.map +1 -0
- package/dist/interactions/shared/interactionImage.d.ts +32 -0
- package/dist/interactions/shared/interactionImage.js +39 -0
- package/dist/interactions/shared/interactionImage.js.map +1 -0
- package/dist/interactions/shared/specDefaults.d.ts +20 -0
- package/dist/interactions/shared/specDefaults.js +25 -0
- package/dist/interactions/shared/specDefaults.js.map +1 -0
- package/dist/interactions/shared/types.d.ts +212 -40
- package/dist/interactions/shared/types.js.map +1 -1
- package/dist/interactions/text-entry/extractor.d.ts +9 -0
- package/dist/interactions/text-entry/extractor.js +9 -0
- package/dist/interactions/text-entry/extractor.js.map +1 -1
- package/dist/interactions/text-entry/inlineInputStyle.d.ts +10 -0
- package/dist/interactions/text-entry/inlineInputStyle.js +12 -0
- package/dist/interactions/text-entry/inlineInputStyle.js.map +1 -0
- package/dist/interactions/text-entry/inputMode.d.ts +35 -0
- package/dist/interactions/text-entry/inputMode.js +134 -0
- package/dist/interactions/text-entry/inputMode.js.map +1 -0
- package/dist/interactions/text-entry/response.d.ts +15 -0
- package/dist/interactions/text-entry/response.js +25 -0
- package/dist/interactions/text-entry/response.js.map +1 -0
- package/dist/interactions/upload/extractor.js +2 -2
- package/dist/interactions/upload/extractor.js.map +1 -1
- package/dist/pci/PciHost.d.ts +1 -1
- package/dist/pci/PciHost.js +11 -11
- package/dist/pci/PciHost.js.map +1 -1
- package/dist/pci/index.d.ts +1 -0
- package/dist/pci/index.js.map +1 -1
- package/dist/pci/modulePaths.d.ts +16 -0
- package/dist/pci/modulePaths.js +33 -0
- package/dist/pci/modulePaths.js.map +1 -0
- package/dist/pci/pageRealmSession.js +3 -15
- package/dist/pci/pageRealmSession.js.map +1 -1
- package/dist/pci/qtiVariableJson.d.ts +46 -3
- package/dist/pci/qtiVariableJson.js +247 -53
- package/dist/pci/qtiVariableJson.js.map +1 -1
- package/dist/pci/sandbox/SandboxedPciSession.d.ts +3 -0
- package/dist/pci/sandbox/SandboxedPciSession.js +15 -14
- package/dist/pci/sandbox/SandboxedPciSession.js.map +1 -1
- package/dist/pci/sandbox/iframeConnector.d.ts +18 -4
- package/dist/pci/sandbox/iframeConnector.js +35 -6
- package/dist/pci/sandbox/iframeConnector.js.map +1 -1
- package/dist/pci/sandbox/protocol.d.ts +14 -0
- package/dist/pci/sandbox/protocol.js.map +1 -1
- package/dist/pci/sessionHosts.d.ts +47 -0
- package/dist/pci/sessionHosts.js +66 -0
- package/dist/pci/sessionHosts.js.map +1 -0
- package/dist/pci/types.d.ts +9 -3
- package/dist/pci/types.js.map +1 -1
- package/dist/pnp/applyPnp.d.ts +20 -3
- package/dist/pnp/applyPnp.js +84 -9
- package/dist/pnp/applyPnp.js.map +1 -1
- package/dist/pnp/parsePnpXml.js +2 -0
- package/dist/pnp/parsePnpXml.js.map +1 -1
- package/dist/pnp/types.d.ts +16 -8
- package/dist/pnp/types.js.map +1 -1
- package/dist/presentation/feedbackAnnouncement.d.ts +56 -0
- package/dist/presentation/feedbackAnnouncement.js +150 -0
- package/dist/presentation/feedbackAnnouncement.js.map +1 -0
- package/dist/presentation/interactionSlots.d.ts +31 -0
- package/dist/presentation/interactionSlots.js +101 -0
- package/dist/presentation/interactionSlots.js.map +1 -0
- package/dist/presentation/itemPresentationPlan.d.ts +69 -6
- package/dist/presentation/itemPresentationPlan.js +93 -81
- package/dist/presentation/itemPresentationPlan.js.map +1 -1
- package/dist/{components/utils → presentation}/stimulusRender.js +3 -12
- package/dist/presentation/stimulusRender.js.map +1 -0
- package/dist/presentation/stylesheetRender.js.map +1 -0
- package/dist/security/escapeHtml.d.ts +15 -0
- package/dist/security/escapeHtml.js +22 -0
- package/dist/security/escapeHtml.js.map +1 -0
- package/dist/security/index.d.ts +1 -0
- package/dist/security/index.js +1 -0
- package/dist/security/index.js.map +1 -1
- package/dist/server.d.ts +8 -1
- package/dist/server.js.map +1 -1
- package/dist/session-inputs.d.ts +108 -0
- package/dist/session-inputs.js +130 -0
- package/dist/session-inputs.js.map +1 -0
- package/dist/types/index.d.ts +67 -35
- package/dist/types/index.js.map +1 -1
- package/dist/utils/cloneFreeze.d.ts +52 -0
- package/dist/utils/cloneFreeze.js +113 -0
- package/dist/utils/cloneFreeze.js.map +1 -0
- package/dist/utils/htmlAttributes.d.ts +13 -0
- package/dist/utils/htmlAttributes.js +22 -0
- package/dist/utils/htmlAttributes.js.map +1 -0
- package/dist/web-components/QTIInteractionElement.d.ts +0 -29
- package/dist/web-components/QTIInteractionElement.js +0 -32
- package/dist/web-components/QTIInteractionElement.js.map +1 -1
- package/dist/web-components/index.d.ts +1 -2
- package/dist/web-components/index.js +2 -3
- package/dist/web-components/index.js.map +1 -1
- package/package.json +20 -19
- package/dist/components/utils/stimulusRender.js.map +0 -1
- package/dist/components/utils/stylesheetRender.js.map +0 -1
- package/dist/core/constants.d.ts +0 -65
- package/dist/core/constants.js +0 -74
- package/dist/core/constants.js.map +0 -1
- package/dist/element-class-DdpiTalY.js +0 -9226
- package/dist/element-class-DdpiTalY.js.map +0 -1
- package/dist/extensions/MathLiveEditor.d.ts +0 -31
- package/dist/extensions/MathLiveEditor.js +0 -248
- package/dist/extensions/MathLiveEditor.js.map +0 -1
- package/dist/utils/PerformanceMonitor.d.ts +0 -169
- package/dist/utils/PerformanceMonitor.js +0 -243
- package/dist/utils/PerformanceMonitor.js.map +0 -1
- package/dist/utils/responseUtils.d.ts +0 -15
- package/dist/utils/responseUtils.js +0 -46
- package/dist/utils/responseUtils.js.map +0 -1
- package/dist/web-components/QTIInteractionBase.d.ts +0 -119
- package/dist/web-components/QTIInteractionBase.js +0 -244
- package/dist/web-components/QTIInteractionBase.js.map +0 -1
- /package/dist/{components/utils → presentation}/stimulusRender.d.ts +0 -0
- /package/dist/{components/utils → presentation}/stylesheetRender.d.ts +0 -0
- /package/dist/{components/utils → presentation}/stylesheetRender.js +0 -0
package/dist/server.js.map
CHANGED
|
@@ -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;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"]}
|
|
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;AA4N5C,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\tItemSessionView as InternalItemSessionView,\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\t/** Present only on response variables that have or had a correct response; null when it is NULL. */\n\tcorrectResponse?: 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\t/** String comparison folds beyond QTI's equality; see `AssessmentItemDefinitionConfig.stringComparison`. */\n\treadonly stringComparison?: Readonly<{\n\t\tfoldScriptInput?: boolean;\n\t\tfoldLetterVariants?: boolean;\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// The Server* types mirror the engine's own so this entry exports no DOM-bearing engine type.\n// Each mirror below must stay assignable in the direction the adapter's casts rely on: engine\n// output to its Server mirror, Server input to the engine's. When the two drift apart, the\n// constraint fails the type check. The ambient declaration emits no code and no declaration.\n// Not listed, because the mirror deliberately differs in the cast direction: the transition (the\n// engine's command union also carries the browser-only `updatePnp`), and the definition config\n// and open options (their mirrors widen `baseType`/`cardinality` to `string`).\ntype MirrorHolds<Relation extends true> = Relation;\ndeclare const serverMirrorsEngine: {\n\tresult: MirrorHolds<InternalItemSessionActionResult extends ServerItemSessionActionResult ? true : false>;\n\tstate: MirrorHolds<InternalSerializedItemSessionState extends ServerSerializedItemSessionState ? true : false>;\n\tview: MirrorHolds<InternalItemSessionView extends ServerItemSessionView ? true : false>;\n\tcommand: MirrorHolds<ServerItemSessionActionCommand extends InternalItemSessionCommand ? true : false>;\n};\n"]}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The canonical descriptor of the definition-fixed session inputs of
|
|
3
|
+
* `<pie-qti-item-player>` and the `ItemPlayer` component.
|
|
4
|
+
*
|
|
5
|
+
* A change to any input listed here re-opens the item session the player owns; every
|
|
6
|
+
* other property write — disabled, i18n, typeset, responses, a no-op — must leave the
|
|
7
|
+
* session alone. Two implementations must agree on this list, so both consume this
|
|
8
|
+
* descriptor and nothing else may maintain it:
|
|
9
|
+
*
|
|
10
|
+
* - `element-class.ts`: each input's setter stores through `SESSION_INPUTS[key].store`
|
|
11
|
+
* and retires the owned session when `SESSION_INPUTS[key].changed` reports a new
|
|
12
|
+
* definition.
|
|
13
|
+
* - `components/ItemPlayer.svelte`: each input has an equality-guarded `$derived`
|
|
14
|
+
* normalizing the prop through `SESSION_INPUTS[key].sessionValue` (the
|
|
15
|
+
* `sessionInputGuards` map there names them), so no-op writes never re-run the
|
|
16
|
+
* session effect.
|
|
17
|
+
*
|
|
18
|
+
* Svelte's `$derived` expressions cannot be generated at runtime, so the component
|
|
19
|
+
* side is written out by hand; the `sessionInputGuards` map pins it to this
|
|
20
|
+
* descriptor at compile time, and
|
|
21
|
+
* `tests/component/element-session-stability.vitest.ts` enforces the lockstep
|
|
22
|
+
* behaviorally by flipping every input here against the mounted element and watching
|
|
23
|
+
* the session. A definition-fixed input is added in this file and on both sides —
|
|
24
|
+
* nowhere else.
|
|
25
|
+
*/
|
|
26
|
+
import type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';
|
|
27
|
+
import type { AssessmentItemDefinitionConfig, AssessmentItemDefinitionPlugin } from './core/AssessmentItemDefinition.js';
|
|
28
|
+
import type { PnpProfile } from './pnp/types.js';
|
|
29
|
+
import type { PlayerSecurityConfig, QTIRole } from './types/index.js';
|
|
30
|
+
/** The stored shape of each session input, as the element's getters report it. */
|
|
31
|
+
export interface SessionInputValues {
|
|
32
|
+
itemXml: string;
|
|
33
|
+
role: QTIRole;
|
|
34
|
+
security: PlayerSecurityConfig | undefined;
|
|
35
|
+
pnp: PnpProfile | undefined;
|
|
36
|
+
deliveryContext: ResolvedItemDeliveryContext | undefined;
|
|
37
|
+
resolveProcessingFragment: AssessmentItemDefinitionConfig['resolveProcessingFragment'];
|
|
38
|
+
processingFragmentLimits: AssessmentItemDefinitionConfig['processingFragmentLimits'];
|
|
39
|
+
pci: AssessmentItemDefinitionConfig['pci'];
|
|
40
|
+
stringComparison: AssessmentItemDefinitionConfig['stringComparison'];
|
|
41
|
+
plugins: readonly AssessmentItemDefinitionPlugin[] | undefined;
|
|
42
|
+
showFeedback: boolean | undefined;
|
|
43
|
+
showSolution: boolean | undefined;
|
|
44
|
+
}
|
|
45
|
+
/** The value shapes the element's setters accept, before `store` normalizes them. */
|
|
46
|
+
export interface SessionInputRawValues {
|
|
47
|
+
itemXml: string | undefined;
|
|
48
|
+
role: QTIRole | null;
|
|
49
|
+
security: PlayerSecurityConfig | undefined;
|
|
50
|
+
pnp: PnpProfile | undefined;
|
|
51
|
+
deliveryContext: ResolvedItemDeliveryContext | undefined;
|
|
52
|
+
resolveProcessingFragment: AssessmentItemDefinitionConfig['resolveProcessingFragment'];
|
|
53
|
+
processingFragmentLimits: AssessmentItemDefinitionConfig['processingFragmentLimits'];
|
|
54
|
+
pci: AssessmentItemDefinitionConfig['pci'];
|
|
55
|
+
stringComparison: AssessmentItemDefinitionConfig['stringComparison'];
|
|
56
|
+
plugins: readonly AssessmentItemDefinitionPlugin[] | undefined;
|
|
57
|
+
showFeedback: boolean | undefined;
|
|
58
|
+
showSolution: boolean | undefined;
|
|
59
|
+
}
|
|
60
|
+
export type SessionInputKey = keyof SessionInputValues;
|
|
61
|
+
export type SessionInputValue<K extends SessionInputKey> = SessionInputValues[K];
|
|
62
|
+
export type SessionInputRaw<K extends SessionInputKey> = SessionInputRawValues[K];
|
|
63
|
+
/**
|
|
64
|
+
* The values the player's session-guard deriveds yield. They narrow the stored value
|
|
65
|
+
* where the session only consumes a normalized form: the standalone session applies
|
|
66
|
+
* `showFeedback` / `showSolution` as QTI `itemSessionControl` does, where `undefined`
|
|
67
|
+
* and `false` are the same policy, so the guarded value is a plain `boolean`.
|
|
68
|
+
*/
|
|
69
|
+
export type SessionInputGuardValues = {
|
|
70
|
+
[K in Exclude<SessionInputKey, 'showFeedback' | 'showSolution'>]: SessionInputValues[K];
|
|
71
|
+
} & {
|
|
72
|
+
showFeedback: boolean;
|
|
73
|
+
showSolution: boolean;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* The change semantics of one definition-fixed input. `store` normalizes an incoming
|
|
77
|
+
* value so equal definitions are stored identically where possible; `changed` decides
|
|
78
|
+
* whether a stored value and a stored next value are different definitions (retire /
|
|
79
|
+
* re-open) or the same one (keep the session); `sessionValue` is the value the
|
|
80
|
+
* component's session-guard derived yields, which must be identical across no-op
|
|
81
|
+
* writes so the session effect does not re-run.
|
|
82
|
+
*/
|
|
83
|
+
export interface SessionInputSemantics<TValue, TRaw, TGuarded = TValue> {
|
|
84
|
+
store(value: TRaw): TValue;
|
|
85
|
+
changed(previous: TValue, next: TValue): boolean;
|
|
86
|
+
sessionValue(value: TValue): TGuarded;
|
|
87
|
+
}
|
|
88
|
+
export type SessionInputDescriptor = {
|
|
89
|
+
[K in SessionInputKey]: SessionInputSemantics<SessionInputValues[K], SessionInputRawValues[K], SessionInputGuardValues[K]>;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* The definition-fixed session inputs, keyed by property name. The semantics entries
|
|
93
|
+
* carry the per-input change decisions both consuming sides share:
|
|
94
|
+
*
|
|
95
|
+
* - Reference inputs (`security`, `pnp`, `deliveryContext`, `pci`,
|
|
96
|
+
* `resolveProcessingFragment`, `processingFragmentLimits`): any newly created
|
|
97
|
+
* object, array or function the host assigns is a new definition.
|
|
98
|
+
* - `itemXml`: the empty string and `undefined` are the same definition (no item).
|
|
99
|
+
* - `role`: parsed first — unknown values render as `candidate` — so two unknown
|
|
100
|
+
* values are one definition.
|
|
101
|
+
* - `stringComparison` and `plugins`: equal option records / plugin lists stored as a
|
|
102
|
+
* frozen copy keep the session; only different content is a new definition.
|
|
103
|
+
* - `showFeedback` / `showSolution`: `undefined` and `false` are the same policy, so
|
|
104
|
+
* the guard compares `?? false` on both sides.
|
|
105
|
+
*/
|
|
106
|
+
export declare const SESSION_INPUTS: SessionInputDescriptor;
|
|
107
|
+
/** The definition-fixed session inputs as a stable, iterable list of property names. */
|
|
108
|
+
export declare const SESSION_INPUT_KEYS: SessionInputKey[];
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The canonical descriptor of the definition-fixed session inputs of
|
|
3
|
+
* `<pie-qti-item-player>` and the `ItemPlayer` component.
|
|
4
|
+
*
|
|
5
|
+
* A change to any input listed here re-opens the item session the player owns; every
|
|
6
|
+
* other property write — disabled, i18n, typeset, responses, a no-op — must leave the
|
|
7
|
+
* session alone. Two implementations must agree on this list, so both consume this
|
|
8
|
+
* descriptor and nothing else may maintain it:
|
|
9
|
+
*
|
|
10
|
+
* - `element-class.ts`: each input's setter stores through `SESSION_INPUTS[key].store`
|
|
11
|
+
* and retires the owned session when `SESSION_INPUTS[key].changed` reports a new
|
|
12
|
+
* definition.
|
|
13
|
+
* - `components/ItemPlayer.svelte`: each input has an equality-guarded `$derived`
|
|
14
|
+
* normalizing the prop through `SESSION_INPUTS[key].sessionValue` (the
|
|
15
|
+
* `sessionInputGuards` map there names them), so no-op writes never re-run the
|
|
16
|
+
* session effect.
|
|
17
|
+
*
|
|
18
|
+
* Svelte's `$derived` expressions cannot be generated at runtime, so the component
|
|
19
|
+
* side is written out by hand; the `sessionInputGuards` map pins it to this
|
|
20
|
+
* descriptor at compile time, and
|
|
21
|
+
* `tests/component/element-session-stability.vitest.ts` enforces the lockstep
|
|
22
|
+
* behaviorally by flipping every input here against the mounted element and watching
|
|
23
|
+
* the session. A definition-fixed input is added in this file and on both sides —
|
|
24
|
+
* nowhere else.
|
|
25
|
+
*/
|
|
26
|
+
import { parseQtiRole } from './core/rolePolicy.js';
|
|
27
|
+
// The role list and its parser live in core/rolePolicy.ts — the one copy every
|
|
28
|
+
// player element shares.
|
|
29
|
+
/** Shallow list equality, so re-assigning an equal list is not a new definition. */
|
|
30
|
+
function sameList(a, b) {
|
|
31
|
+
if (a === b)
|
|
32
|
+
return true;
|
|
33
|
+
if (!a || !b || a.length !== b.length)
|
|
34
|
+
return false;
|
|
35
|
+
return a.every((entry, index) => entry === b[index]);
|
|
36
|
+
}
|
|
37
|
+
/** Shallow record equality for flat option objects. */
|
|
38
|
+
function sameRecord(a, b) {
|
|
39
|
+
if (a === b)
|
|
40
|
+
return true;
|
|
41
|
+
if (!a || !b)
|
|
42
|
+
return false;
|
|
43
|
+
const keys = Object.keys(a);
|
|
44
|
+
return (keys.length === Object.keys(b).length &&
|
|
45
|
+
keys.every((key) => a[key] === b[key]));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The definition-fixed session inputs, keyed by property name. The semantics entries
|
|
49
|
+
* carry the per-input change decisions both consuming sides share:
|
|
50
|
+
*
|
|
51
|
+
* - Reference inputs (`security`, `pnp`, `deliveryContext`, `pci`,
|
|
52
|
+
* `resolveProcessingFragment`, `processingFragmentLimits`): any newly created
|
|
53
|
+
* object, array or function the host assigns is a new definition.
|
|
54
|
+
* - `itemXml`: the empty string and `undefined` are the same definition (no item).
|
|
55
|
+
* - `role`: parsed first — unknown values render as `candidate` — so two unknown
|
|
56
|
+
* values are one definition.
|
|
57
|
+
* - `stringComparison` and `plugins`: equal option records / plugin lists stored as a
|
|
58
|
+
* frozen copy keep the session; only different content is a new definition.
|
|
59
|
+
* - `showFeedback` / `showSolution`: `undefined` and `false` are the same policy, so
|
|
60
|
+
* the guard compares `?? false` on both sides.
|
|
61
|
+
*/
|
|
62
|
+
export const SESSION_INPUTS = {
|
|
63
|
+
itemXml: {
|
|
64
|
+
store: (value) => value ?? '',
|
|
65
|
+
changed: (previous, next) => previous !== next,
|
|
66
|
+
sessionValue: (value) => value,
|
|
67
|
+
},
|
|
68
|
+
role: {
|
|
69
|
+
store: (value) => parseQtiRole(value ?? undefined),
|
|
70
|
+
changed: (previous, next) => previous !== next,
|
|
71
|
+
sessionValue: (value) => value,
|
|
72
|
+
},
|
|
73
|
+
security: {
|
|
74
|
+
store: (value) => value,
|
|
75
|
+
changed: (previous, next) => previous !== next,
|
|
76
|
+
sessionValue: (value) => value,
|
|
77
|
+
},
|
|
78
|
+
pnp: {
|
|
79
|
+
store: (value) => value,
|
|
80
|
+
changed: (previous, next) => previous !== next,
|
|
81
|
+
sessionValue: (value) => value,
|
|
82
|
+
},
|
|
83
|
+
deliveryContext: {
|
|
84
|
+
store: (value) => value,
|
|
85
|
+
changed: (previous, next) => previous !== next,
|
|
86
|
+
sessionValue: (value) => value,
|
|
87
|
+
},
|
|
88
|
+
resolveProcessingFragment: {
|
|
89
|
+
store: (value) => value,
|
|
90
|
+
changed: (previous, next) => previous !== next,
|
|
91
|
+
sessionValue: (value) => value,
|
|
92
|
+
},
|
|
93
|
+
processingFragmentLimits: {
|
|
94
|
+
store: (value) => value,
|
|
95
|
+
changed: (previous, next) => previous !== next,
|
|
96
|
+
sessionValue: (value) => value,
|
|
97
|
+
},
|
|
98
|
+
pci: {
|
|
99
|
+
store: (value) => value,
|
|
100
|
+
changed: (previous, next) => previous !== next,
|
|
101
|
+
sessionValue: (value) => value,
|
|
102
|
+
},
|
|
103
|
+
stringComparison: {
|
|
104
|
+
// Keep the frozen copy when the options are unchanged: a re-assigned equal object
|
|
105
|
+
// is not a new definition and must not re-open the session.
|
|
106
|
+
store: (value) => (value ? Object.freeze({ ...value }) : undefined),
|
|
107
|
+
changed: (previous, next) => !sameRecord(previous, next),
|
|
108
|
+
sessionValue: (value) => value,
|
|
109
|
+
},
|
|
110
|
+
plugins: {
|
|
111
|
+
// Keep the frozen copy when the same plugins are re-assigned: an equal list is not
|
|
112
|
+
// a new definition and must not re-open the session.
|
|
113
|
+
store: (value) => (value ? Object.freeze([...value]) : undefined),
|
|
114
|
+
changed: (previous, next) => !sameList(previous, next),
|
|
115
|
+
sessionValue: (value) => value,
|
|
116
|
+
},
|
|
117
|
+
showFeedback: {
|
|
118
|
+
store: (value) => value,
|
|
119
|
+
changed: (previous, next) => (previous ?? false) !== (next ?? false),
|
|
120
|
+
sessionValue: (value) => value ?? false,
|
|
121
|
+
},
|
|
122
|
+
showSolution: {
|
|
123
|
+
store: (value) => value,
|
|
124
|
+
changed: (previous, next) => (previous ?? false) !== (next ?? false),
|
|
125
|
+
sessionValue: (value) => value ?? false,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
/** The definition-fixed session inputs as a stable, iterable list of property names. */
|
|
129
|
+
export const SESSION_INPUT_KEYS = Object.keys(SESSION_INPUTS);
|
|
130
|
+
//# sourceMappingURL=session-inputs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-inputs.js","sourceRoot":"","sources":["../src/session-inputs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAQH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AA2EpD,+EAA+E;AAC/E,yBAAyB;AAEzB,oFAAoF;AACpF,SAAS,QAAQ,CAAC,CAAiC,EAAE,CAAiC;IACrF,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACpD,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,uDAAuD;AACvD,SAAS,UAAU,CAAC,CAAqB,EAAE,CAAqB;IAC/D,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5B,OAAO,CACN,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM;QACrC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAE,CAA6B,CAAC,GAAG,CAAC,KAAM,CAA6B,CAAC,GAAG,CAAC,CAAC,CAChG,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,cAAc,GAA2B;IACrD,OAAO,EAAE;QACR,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE;QAC7B,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,KAAK,IAAI;QAC9C,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;KAC9B;IACD,IAAI,EAAE;QACL,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,IAAI,SAAS,CAAC;QAClD,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,KAAK,IAAI;QAC9C,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;KAC9B;IACD,QAAQ,EAAE;QACT,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;QACvB,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,KAAK,IAAI;QAC9C,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;KAC9B;IACD,GAAG,EAAE;QACJ,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;QACvB,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,KAAK,IAAI;QAC9C,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;KAC9B;IACD,eAAe,EAAE;QAChB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;QACvB,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,KAAK,IAAI;QAC9C,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;KAC9B;IACD,yBAAyB,EAAE;QAC1B,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;QACvB,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,KAAK,IAAI;QAC9C,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;KAC9B;IACD,wBAAwB,EAAE;QACzB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;QACvB,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,KAAK,IAAI;QAC9C,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;KAC9B;IACD,GAAG,EAAE;QACJ,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;QACvB,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,KAAK,IAAI;QAC9C,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;KAC9B;IACD,gBAAgB,EAAE;QACjB,kFAAkF;QAClF,4DAA4D;QAC5D,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACnE,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC;QACxD,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;KAC9B;IACD,OAAO,EAAE;QACR,mFAAmF;QACnF,qDAAqD;QACrD,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACjE,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;QACtD,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;KAC9B;IACD,YAAY,EAAE;QACb,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;QACvB,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC;QACpE,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,KAAK;KACvC;IACD,YAAY,EAAE;QACb,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;QACvB,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC;QACpE,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,KAAK;KACvC;CACD,CAAC;AAEF,wFAAwF;AACxF,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAsB,CAAC","sourcesContent":["/**\n * The canonical descriptor of the definition-fixed session inputs of\n * `<pie-qti-item-player>` and the `ItemPlayer` component.\n *\n * A change to any input listed here re-opens the item session the player owns; every\n * other property write — disabled, i18n, typeset, responses, a no-op — must leave the\n * session alone. Two implementations must agree on this list, so both consume this\n * descriptor and nothing else may maintain it:\n *\n * - `element-class.ts`: each input's setter stores through `SESSION_INPUTS[key].store`\n * and retires the owned session when `SESSION_INPUTS[key].changed` reports a new\n * definition.\n * - `components/ItemPlayer.svelte`: each input has an equality-guarded `$derived`\n * normalizing the prop through `SESSION_INPUTS[key].sessionValue` (the\n * `sessionInputGuards` map there names them), so no-op writes never re-run the\n * session effect.\n *\n * Svelte's `$derived` expressions cannot be generated at runtime, so the component\n * side is written out by hand; the `sessionInputGuards` map pins it to this\n * descriptor at compile time, and\n * `tests/component/element-session-stability.vitest.ts` enforces the lockstep\n * behaviorally by flipping every input here against the mounted element and watching\n * the session. A definition-fixed input is added in this file and on both sides —\n * nowhere else.\n */\n\nimport type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';\nimport type { ProcessingFragmentResolver } from '@pie-qti/qti-processing';\nimport type {\n\tAssessmentItemDefinitionConfig,\n\tAssessmentItemDefinitionPlugin,\n} from './core/AssessmentItemDefinition.js';\nimport { parseQtiRole } from './core/rolePolicy.js';\nimport type { PnpProfile } from './pnp/types.js';\nimport type { PlayerSecurityConfig, QTIRole } from './types/index.js';\n\n/** The stored shape of each session input, as the element's getters report it. */\nexport interface SessionInputValues {\n\titemXml: string;\n\trole: QTIRole;\n\tsecurity: PlayerSecurityConfig | undefined;\n\tpnp: PnpProfile | undefined;\n\tdeliveryContext: ResolvedItemDeliveryContext | undefined;\n\tresolveProcessingFragment: AssessmentItemDefinitionConfig['resolveProcessingFragment'];\n\tprocessingFragmentLimits: AssessmentItemDefinitionConfig['processingFragmentLimits'];\n\tpci: AssessmentItemDefinitionConfig['pci'];\n\tstringComparison: AssessmentItemDefinitionConfig['stringComparison'];\n\tplugins: readonly AssessmentItemDefinitionPlugin[] | undefined;\n\tshowFeedback: boolean | undefined;\n\tshowSolution: boolean | undefined;\n}\n\n/** The value shapes the element's setters accept, before `store` normalizes them. */\nexport interface SessionInputRawValues {\n\titemXml: string | undefined;\n\trole: QTIRole | null;\n\tsecurity: PlayerSecurityConfig | undefined;\n\tpnp: PnpProfile | undefined;\n\tdeliveryContext: ResolvedItemDeliveryContext | undefined;\n\tresolveProcessingFragment: AssessmentItemDefinitionConfig['resolveProcessingFragment'];\n\tprocessingFragmentLimits: AssessmentItemDefinitionConfig['processingFragmentLimits'];\n\tpci: AssessmentItemDefinitionConfig['pci'];\n\tstringComparison: AssessmentItemDefinitionConfig['stringComparison'];\n\tplugins: readonly AssessmentItemDefinitionPlugin[] | undefined;\n\tshowFeedback: boolean | undefined;\n\tshowSolution: boolean | undefined;\n}\n\nexport type SessionInputKey = keyof SessionInputValues;\nexport type SessionInputValue<K extends SessionInputKey> = SessionInputValues[K];\nexport type SessionInputRaw<K extends SessionInputKey> = SessionInputRawValues[K];\n\n/**\n * The values the player's session-guard deriveds yield. They narrow the stored value\n * where the session only consumes a normalized form: the standalone session applies\n * `showFeedback` / `showSolution` as QTI `itemSessionControl` does, where `undefined`\n * and `false` are the same policy, so the guarded value is a plain `boolean`.\n */\nexport type SessionInputGuardValues = {\n\t[K in Exclude<SessionInputKey, 'showFeedback' | 'showSolution'>]: SessionInputValues[K];\n} & {\n\tshowFeedback: boolean;\n\tshowSolution: boolean;\n};\n\n/**\n * The change semantics of one definition-fixed input. `store` normalizes an incoming\n * value so equal definitions are stored identically where possible; `changed` decides\n * whether a stored value and a stored next value are different definitions (retire /\n * re-open) or the same one (keep the session); `sessionValue` is the value the\n * component's session-guard derived yields, which must be identical across no-op\n * writes so the session effect does not re-run.\n */\nexport interface SessionInputSemantics<TValue, TRaw, TGuarded = TValue> {\n\tstore(value: TRaw): TValue;\n\tchanged(previous: TValue, next: TValue): boolean;\n\tsessionValue(value: TValue): TGuarded;\n}\n\nexport type SessionInputDescriptor = {\n\t[K in SessionInputKey]: SessionInputSemantics<\n\t\tSessionInputValues[K],\n\t\tSessionInputRawValues[K],\n\t\tSessionInputGuardValues[K]\n\t>;\n};\n\n// The role list and its parser live in core/rolePolicy.ts — the one copy every\n// player element shares.\n\n/** Shallow list equality, so re-assigning an equal list is not a new definition. */\nfunction sameList(a: readonly unknown[] | undefined, b: readonly unknown[] | undefined): boolean {\n\tif (a === b) return true;\n\tif (!a || !b || a.length !== b.length) return false;\n\treturn a.every((entry, index) => entry === b[index]);\n}\n\n/** Shallow record equality for flat option objects. */\nfunction sameRecord(a: object | undefined, b: object | undefined): boolean {\n\tif (a === b) return true;\n\tif (!a || !b) return false;\n\tconst keys = Object.keys(a);\n\treturn (\n\t\tkeys.length === Object.keys(b).length &&\n\t\tkeys.every((key) => (a as Record<string, unknown>)[key] === (b as Record<string, unknown>)[key])\n\t);\n}\n\n/**\n * The definition-fixed session inputs, keyed by property name. The semantics entries\n * carry the per-input change decisions both consuming sides share:\n *\n * - Reference inputs (`security`, `pnp`, `deliveryContext`, `pci`,\n * `resolveProcessingFragment`, `processingFragmentLimits`): any newly created\n * object, array or function the host assigns is a new definition.\n * - `itemXml`: the empty string and `undefined` are the same definition (no item).\n * - `role`: parsed first — unknown values render as `candidate` — so two unknown\n * values are one definition.\n * - `stringComparison` and `plugins`: equal option records / plugin lists stored as a\n * frozen copy keep the session; only different content is a new definition.\n * - `showFeedback` / `showSolution`: `undefined` and `false` are the same policy, so\n * the guard compares `?? false` on both sides.\n */\nexport const SESSION_INPUTS: SessionInputDescriptor = {\n\titemXml: {\n\t\tstore: (value) => value ?? '',\n\t\tchanged: (previous, next) => previous !== next,\n\t\tsessionValue: (value) => value,\n\t},\n\trole: {\n\t\tstore: (value) => parseQtiRole(value ?? undefined),\n\t\tchanged: (previous, next) => previous !== next,\n\t\tsessionValue: (value) => value,\n\t},\n\tsecurity: {\n\t\tstore: (value) => value,\n\t\tchanged: (previous, next) => previous !== next,\n\t\tsessionValue: (value) => value,\n\t},\n\tpnp: {\n\t\tstore: (value) => value,\n\t\tchanged: (previous, next) => previous !== next,\n\t\tsessionValue: (value) => value,\n\t},\n\tdeliveryContext: {\n\t\tstore: (value) => value,\n\t\tchanged: (previous, next) => previous !== next,\n\t\tsessionValue: (value) => value,\n\t},\n\tresolveProcessingFragment: {\n\t\tstore: (value) => value,\n\t\tchanged: (previous, next) => previous !== next,\n\t\tsessionValue: (value) => value,\n\t},\n\tprocessingFragmentLimits: {\n\t\tstore: (value) => value,\n\t\tchanged: (previous, next) => previous !== next,\n\t\tsessionValue: (value) => value,\n\t},\n\tpci: {\n\t\tstore: (value) => value,\n\t\tchanged: (previous, next) => previous !== next,\n\t\tsessionValue: (value) => value,\n\t},\n\tstringComparison: {\n\t\t// Keep the frozen copy when the options are unchanged: a re-assigned equal object\n\t\t// is not a new definition and must not re-open the session.\n\t\tstore: (value) => (value ? Object.freeze({ ...value }) : undefined),\n\t\tchanged: (previous, next) => !sameRecord(previous, next),\n\t\tsessionValue: (value) => value,\n\t},\n\tplugins: {\n\t\t// Keep the frozen copy when the same plugins are re-assigned: an equal list is not\n\t\t// a new definition and must not re-open the session.\n\t\tstore: (value) => (value ? Object.freeze([...value]) : undefined),\n\t\tchanged: (previous, next) => !sameList(previous, next),\n\t\tsessionValue: (value) => value,\n\t},\n\tshowFeedback: {\n\t\tstore: (value) => value,\n\t\tchanged: (previous, next) => (previous ?? false) !== (next ?? false),\n\t\tsessionValue: (value) => value ?? false,\n\t},\n\tshowSolution: {\n\t\tstore: (value) => value,\n\t\tchanged: (previous, next) => (previous ?? false) !== (next ?? false),\n\t\tsessionValue: (value) => value ?? false,\n\t},\n};\n\n/** The definition-fixed session inputs as a stable, iterable list of property names. */\nexport const SESSION_INPUT_KEYS = Object.keys(SESSION_INPUTS) as SessionInputKey[];\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -27,11 +27,6 @@ export interface Mapping {
|
|
|
27
27
|
defaultValue?: number;
|
|
28
28
|
lowerBound?: number;
|
|
29
29
|
upperBound?: number;
|
|
30
|
-
/**
|
|
31
|
-
* QTI attribute on <mapping>. When "false", string mappings are case-insensitive by default.
|
|
32
|
-
* Stored as raw string to match XML attribute values ("true"/"false").
|
|
33
|
-
*/
|
|
34
|
-
caseSensitive?: string;
|
|
35
30
|
entries: Record<string, MapEntry>;
|
|
36
31
|
}
|
|
37
32
|
export interface MapEntry {
|
|
@@ -53,14 +48,6 @@ export interface AreaMapEntry {
|
|
|
53
48
|
export interface ResponseDeclaration extends VariableDeclaration {
|
|
54
49
|
correctResponse?: any;
|
|
55
50
|
}
|
|
56
|
-
export interface OutcomeDeclaration extends VariableDeclaration {
|
|
57
|
-
interpretation?: string;
|
|
58
|
-
longInterpretation?: string;
|
|
59
|
-
normalMaximum?: number;
|
|
60
|
-
normalMinimum?: number;
|
|
61
|
-
masteryValue?: number;
|
|
62
|
-
views?: string[];
|
|
63
|
-
}
|
|
64
51
|
export type ItemLifecycleStatus = 'initial' | 'interacting' | 'suspended' | 'closed' | 'review' | 'solution' | 'answer';
|
|
65
52
|
export type SerializedVariableKind = 'response' | 'outcome' | 'template' | 'context';
|
|
66
53
|
export interface SerializedItemSessionVariable {
|
|
@@ -70,7 +57,23 @@ export interface SerializedItemSessionVariable {
|
|
|
70
57
|
baseType?: VariableBaseType;
|
|
71
58
|
cardinality: VariableCardinality;
|
|
72
59
|
value: any;
|
|
73
|
-
|
|
60
|
+
/**
|
|
61
|
+
* The variable's default value for this session, which a setDefaultValue
|
|
62
|
+
* template rule can change (QTI 2.1 ASI §8 / QTI 3.0 ASI §10: template-rule
|
|
63
|
+
* effects are fixed for the session); null when the variable has no default
|
|
64
|
+
* value. Restore applies it as-is, so null restores a NULL default rather
|
|
65
|
+
* than the default parsed from the item XML.
|
|
66
|
+
*/
|
|
67
|
+
defaultValue: any;
|
|
68
|
+
/**
|
|
69
|
+
* The response declaration's correct response for this session, including one
|
|
70
|
+
* computed by a setCorrectResponse template rule (QTI 2.1 ASI §8 / QTI 3.0 ASI
|
|
71
|
+
* §10: template-rule effects are fixed for the session). Present on every
|
|
72
|
+
* response variable that has or had a correct response, with null meaning the
|
|
73
|
+
* correct response is NULL; absent when the variable has no correct response.
|
|
74
|
+
* Restore applies it as-is when present.
|
|
75
|
+
*/
|
|
76
|
+
correctResponse?: any;
|
|
74
77
|
}
|
|
75
78
|
export interface SerializedItemSessionState {
|
|
76
79
|
itemIdentifier?: string;
|
|
@@ -79,7 +82,8 @@ export interface SerializedItemSessionState {
|
|
|
79
82
|
completionStatus: CompletionStatus;
|
|
80
83
|
numAttempts: number;
|
|
81
84
|
/**
|
|
82
|
-
* Time
|
|
85
|
+
* Time on task in milliseconds. The QTI built-in `duration` variable (in
|
|
86
|
+
* `contextVariables.duration`) holds the same time in seconds, as QTI defines it.
|
|
83
87
|
*/
|
|
84
88
|
duration: number;
|
|
85
89
|
responseVariables: Record<string, SerializedItemSessionVariable>;
|
|
@@ -110,6 +114,7 @@ export interface ItemSessionActionResult {
|
|
|
110
114
|
lifecycleStatus: ItemLifecycleStatus;
|
|
111
115
|
completionStatus: CompletionStatus;
|
|
112
116
|
numAttempts: number;
|
|
117
|
+
/** Time on task in milliseconds; the QTI `duration` variable holds it in seconds. */
|
|
113
118
|
duration: number;
|
|
114
119
|
completed: boolean;
|
|
115
120
|
sessionState: SerializedItemSessionState;
|
|
@@ -188,6 +193,29 @@ export interface AdaptiveAttemptResult extends ScoringResult {
|
|
|
188
193
|
* policy layered on top of these roles.
|
|
189
194
|
*/
|
|
190
195
|
export type QTIRole = 'candidate' | 'scorer' | 'proctor' | 'testConstructor' | 'tutor' | 'author';
|
|
196
|
+
/**
|
|
197
|
+
* Why an item player reported a failure, as `error.code`. The `message` is raw engine or
|
|
198
|
+
* parser text for host logs only — never render it to candidates.
|
|
199
|
+
*/
|
|
200
|
+
export type ItemPlayerErrorCode = 'item-load-failed' | 'response-processing-failed' | 'response-dispatch-failed' | 'submission-failed' | 'render-failed';
|
|
201
|
+
/** A player failure as hosts receive it: a stable `code`, the raw `message`, and the item when known. */
|
|
202
|
+
export interface ItemPlayerErrorDetail {
|
|
203
|
+
code: ItemPlayerErrorCode;
|
|
204
|
+
/** Raw message, for logs and host diagnostics — never render it to candidates. */
|
|
205
|
+
message: string;
|
|
206
|
+
itemIdentifier?: string;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* A failure the item body reports to its player: the stable `code` the element's
|
|
210
|
+
* `error` event carries, plus the raw cause for host logs. `render-failed` covers
|
|
211
|
+
* interaction mount/update and component-registry failures; the item keeps
|
|
212
|
+
* rendering with a visible placeholder for the failed interaction.
|
|
213
|
+
* `response-dispatch-failed` covers a rejected response write.
|
|
214
|
+
*/
|
|
215
|
+
export interface ItemBodyError {
|
|
216
|
+
code: Extract<ItemPlayerErrorCode, 'render-failed' | 'response-dispatch-failed'>;
|
|
217
|
+
cause: unknown;
|
|
218
|
+
}
|
|
191
219
|
export type RubricBlockScope = 'direct' | 'itemBody';
|
|
192
220
|
export interface RubricBlock {
|
|
193
221
|
view: string[];
|
|
@@ -196,15 +224,25 @@ export interface RubricBlock {
|
|
|
196
224
|
use?: string;
|
|
197
225
|
}
|
|
198
226
|
/**
|
|
199
|
-
* QTI
|
|
200
|
-
*
|
|
227
|
+
* QTI compliance checks run once, when the item compiles. They are not an XSD validator: they check
|
|
228
|
+
* the version's namespace, every element name against the XSD-verified QTI 2.2 / 3.0 vocabulary
|
|
229
|
+
* (unknown QTI-namespace elements, and unknown `qti-` elements in QTI 3.0), interactions whose
|
|
230
|
+
* `responseIdentifier` names no responseDeclaration, QTI interactions with no
|
|
231
|
+
* `responseIdentifier`, and response-bound elements no registered extractor renders.
|
|
232
|
+
*
|
|
233
|
+
* Findings are listed on `AssessmentItemDefinition.diagnostics`: warnings by default, errors in
|
|
234
|
+
* strict mode. An unsupported `responseProcessing@template` always fails compilation with an
|
|
235
|
+
* `UnsupportedResponseProcessingTemplateError`, strict or not.
|
|
201
236
|
*/
|
|
202
237
|
export interface QTIComplianceConfig {
|
|
203
|
-
/**
|
|
238
|
+
/**
|
|
239
|
+
* Strict mode: findings are errors, and items in versions other than QTI 2.2 and 3.0 (the
|
|
240
|
+
* certifiable versions) are findings too. Default: false (findings are warnings).
|
|
241
|
+
*/
|
|
204
242
|
enabled?: boolean;
|
|
205
|
-
/**
|
|
243
|
+
/** In strict mode, throw a `QtiComplianceError` listing every finding instead of compiling. Default: false */
|
|
206
244
|
rejectUnknownExtensions?: boolean;
|
|
207
|
-
/**
|
|
245
|
+
/** Write findings to the console (errors in strict mode, warnings otherwise). Default: true */
|
|
208
246
|
logDeviations?: boolean;
|
|
209
247
|
}
|
|
210
248
|
export interface UrlPolicyConfig {
|
|
@@ -247,8 +285,8 @@ export interface PlayerSecurityConfig {
|
|
|
247
285
|
/** Allow <iframe> usage (default false) */
|
|
248
286
|
allowIframes?: boolean;
|
|
249
287
|
/**
|
|
250
|
-
*
|
|
251
|
-
*
|
|
288
|
+
* Parsing/processing guardrails that reduce DoS risk from untrusted QTI. On by default;
|
|
289
|
+
* `parsingLimits.enabled: false` opts out.
|
|
252
290
|
*/
|
|
253
291
|
parsingLimits?: ParsingLimitsConfig;
|
|
254
292
|
/**
|
|
@@ -261,36 +299,30 @@ export interface PlayerSecurityConfig {
|
|
|
261
299
|
}
|
|
262
300
|
export interface ParsingLimitsConfig {
|
|
263
301
|
/**
|
|
264
|
-
*
|
|
302
|
+
* The limits apply unless this is `false`. Opt out only for trusted content that needs more
|
|
303
|
+
* than the limits allow (or a DOCTYPE), never to accept untrusted QTI.
|
|
265
304
|
*/
|
|
266
305
|
enabled?: boolean;
|
|
267
306
|
/**
|
|
268
|
-
* Reject any XML containing <!DOCTYPE ...> (case-insensitive)
|
|
307
|
+
* Reject any XML containing <!DOCTYPE ...> (case-insensitive). Default true.
|
|
269
308
|
* Helps reduce entity-expansion and other parser edge-case risks.
|
|
270
309
|
*/
|
|
271
310
|
rejectDoctype?: boolean;
|
|
272
311
|
/**
|
|
273
|
-
* Maximum bytes for `itemXml` input (UTF-8).
|
|
312
|
+
* Maximum bytes for `itemXml` input (UTF-8). Default 10,000,000.
|
|
274
313
|
*/
|
|
275
314
|
maxItemXmlBytes?: number;
|
|
276
315
|
/**
|
|
277
|
-
* Maximum bytes for HTML strings passed to sanitizer (UTF-8).
|
|
316
|
+
* Maximum bytes for HTML strings passed to the sanitizer (UTF-8). Default 5,000,000.
|
|
278
317
|
*/
|
|
279
318
|
maxHtmlBytes?: number;
|
|
280
319
|
/**
|
|
281
|
-
* Maximum number of element nodes sanitized per HTML input.
|
|
320
|
+
* Maximum number of element nodes sanitized per HTML input. Default 200,000.
|
|
282
321
|
*/
|
|
283
322
|
maxHtmlNodes?: number;
|
|
284
323
|
/**
|
|
285
|
-
* Maximum element depth sanitized per HTML input.
|
|
324
|
+
* Maximum element depth sanitized per HTML input. Default 200.
|
|
286
325
|
*/
|
|
287
326
|
maxHtmlDepth?: number;
|
|
288
327
|
}
|
|
289
|
-
export interface InteractionContext {
|
|
290
|
-
responseIdentifier: string;
|
|
291
|
-
maxChoices?: number;
|
|
292
|
-
minChoices?: number;
|
|
293
|
-
shuffle?: boolean;
|
|
294
|
-
orientation?: 'horizontal' | 'vertical';
|
|
295
|
-
}
|
|
296
328
|
export * from './responseValidation.js';
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAgcH,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 {\n\tAttributeNameMapper,\n\tElementNameMapper,\n} from '@pie-qti/qti-common';\nimport type { I18nProvider } from '@pie-qti/i18n';\nimport type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';\nimport type { PciConfiguration } from '../pci/types.js';\nimport type { ComponentRegistry } from '../core/ComponentRegistry.js';\nimport type { ExtractionRegistry } from '../extraction/ExtractionRegistry.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?: ElementNameMapper;\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?: AttributeNameMapper;\n\t/** Optional web component registry for custom interaction components */\n\tcomponentRegistry?: ComponentRegistry;\n\t/** Optional extraction registry for custom element extractors */\n\textractionRegistry?: ExtractionRegistry;\n\t/**\n\t * Optional i18n provider for internationalization.\n\t * If not provided, defaults to DefaultI18nProvider with English messages.\n\t */\n\ti18nProvider?: I18nProvider;\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;AA0eH,cAAc,yBAAyB,CAAC","sourcesContent":["/**\n * Core QTI types for the player\n */\n\nimport type { I18nProvider } from '@pie-qti/i18n';\nimport type {\n\tBaseType as ProcessingBaseType,\n\tCardinality as ProcessingCardinality,\n\tProcessingFragmentResolver,\n\tQtiValue,\n\tStringComparisonOptions,\n} from '@pie-qti/qti-processing';\nimport type {\n\tAttributeNameMapper,\n\tElementNameMapper,\n\tQtiVersion,\n} from '@pie-qti/qti-common';\nimport type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';\nimport type { PciConfiguration } from '../pci/types.js';\nimport type { ComponentRegistry } from '../core/ComponentRegistry.js';\nimport type { ExtractionRegistry } from '../extraction/ExtractionRegistry.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\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\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\t/**\n\t * The variable's default value for this session, which a setDefaultValue\n\t * template rule can change (QTI 2.1 ASI §8 / QTI 3.0 ASI §10: template-rule\n\t * effects are fixed for the session); null when the variable has no default\n\t * value. Restore applies it as-is, so null restores a NULL default rather\n\t * than the default parsed from the item XML.\n\t */\n\tdefaultValue: any;\n\t/**\n\t * The response declaration's correct response for this session, including one\n\t * computed by a setCorrectResponse template rule (QTI 2.1 ASI §8 / QTI 3.0 ASI\n\t * §10: template-rule effects are fixed for the session). Present on every\n\t * response variable that has or had a correct response, with null meaning the\n\t * correct response is NULL; absent when the variable has no correct response.\n\t * Restore applies it as-is when present.\n\t */\n\tcorrectResponse?: 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. The QTI built-in `duration` variable (in\n\t * `contextVariables.duration`) holds the same time in seconds, as QTI defines it.\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\t/** Time on task in milliseconds; the QTI `duration` variable holds it in seconds. */\n\tduration: number;\n\tcompleted: boolean;\n\tsessionState: SerializedItemSessionState;\n\tvalidation?: ResponseValidationResult;\n\tscoring?: ScoringResult;\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\n/**\n * Why an item player reported a failure, as `error.code`. The `message` is raw engine or\n * parser text for host logs only — never render it to candidates.\n */\nexport type ItemPlayerErrorCode =\n\t| 'item-load-failed'\n\t| 'response-processing-failed'\n\t| 'response-dispatch-failed'\n\t| 'submission-failed'\n\t| 'render-failed';\n\n/** A player failure as hosts receive it: a stable `code`, the raw `message`, and the item when known. */\nexport interface ItemPlayerErrorDetail {\n\tcode: ItemPlayerErrorCode;\n\t/** Raw message, for logs and host diagnostics — never render it to candidates. */\n\tmessage: string;\n\titemIdentifier?: string;\n}\n\n/**\n * A failure the item body reports to its player: the stable `code` the element's\n * `error` event carries, plus the raw cause for host logs. `render-failed` covers\n * interaction mount/update and component-registry failures; the item keeps\n * rendering with a visible placeholder for the failed interaction.\n * `response-dispatch-failed` covers a rejected response write.\n */\nexport interface ItemBodyError {\n\tcode: Extract<ItemPlayerErrorCode, 'render-failed' | 'response-dispatch-failed'>;\n\tcause: unknown;\n}\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 compliance checks run once, when the item compiles. They are not an XSD validator: they check\n * the version's namespace, every element name against the XSD-verified QTI 2.2 / 3.0 vocabulary\n * (unknown QTI-namespace elements, and unknown `qti-` elements in QTI 3.0), interactions whose\n * `responseIdentifier` names no responseDeclaration, QTI interactions with no\n * `responseIdentifier`, and response-bound elements no registered extractor renders.\n *\n * Findings are listed on `AssessmentItemDefinition.diagnostics`: warnings by default, errors in\n * strict mode. An unsupported `responseProcessing@template` always fails compilation with an\n * `UnsupportedResponseProcessingTemplateError`, strict or not.\n */\nexport interface QTIComplianceConfig {\n\t/**\n\t * Strict mode: findings are errors, and items in versions other than QTI 2.2 and 3.0 (the\n\t * certifiable versions) are findings too. Default: false (findings are warnings).\n\t */\n\tenabled?: boolean;\n\n\t/** In strict mode, throw a `QtiComplianceError` listing every finding instead of compiling. Default: false */\n\trejectUnknownExtensions?: boolean;\n\n\t/** Write findings to the console (errors in strict mode, warnings otherwise). 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?: ElementNameMapper;\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?: AttributeNameMapper;\n\t/**\n\t * The item's detected QTI version, applied by extractors that carry per-version spec\n\t * defaults (e.g. graphicGapMatchInteraction maxAssociations). Detected from the item\n\t * XML when not supplied.\n\t */\n\tqtiVersion?: QtiVersion;\n\t/** Optional web component registry for custom interaction components */\n\tcomponentRegistry?: ComponentRegistry;\n\t/** Optional extraction registry for custom element extractors */\n\textractionRegistry?: ExtractionRegistry;\n\t/**\n\t * Optional i18n provider for internationalization.\n\t * If not provided, defaults to DefaultI18nProvider with English messages.\n\t */\n\ti18nProvider?: I18nProvider;\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/** String comparison folds beyond QTI's equality; see `AssessmentItemDefinitionConfig.stringComparison`. */\n\tstringComparison?: StringComparisonOptions;\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 compliance checks; see `QTIComplianceConfig`. Set `enabled` for strict mode.\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 * Parsing/processing guardrails that reduce DoS risk from untrusted QTI. On by default;\n\t * `parsingLimits.enabled: false` opts out.\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 * The limits apply unless this is `false`. Opt out only for trusted content that needs more\n\t * than the limits allow (or a DOCTYPE), never to accept untrusted QTI.\n\t */\n\tenabled?: boolean;\n\t/**\n\t * Reject any XML containing <!DOCTYPE ...> (case-insensitive). Default true.\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). Default 10,000,000.\n\t */\n\tmaxItemXmlBytes?: number;\n\t/**\n\t * Maximum bytes for HTML strings passed to the sanitizer (UTF-8). Default 5,000,000.\n\t */\n\tmaxHtmlBytes?: number;\n\t/**\n\t * Maximum number of element nodes sanitized per HTML input. Default 200,000.\n\t */\n\tmaxHtmlNodes?: number;\n\t/**\n\t * Maximum element depth sanitized per HTML input. Default 200.\n\t */\n\tmaxHtmlDepth?: number;\n}\n\nexport * from './responseValidation.js';\n"]}
|