@pie-qti/item-player 0.1.28 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -6
- package/dist/catalog/applyGlossaryTriggers.js +8 -2
- package/dist/catalog/applyGlossaryTriggers.js.map +1 -1
- package/dist/catalog/catalogExtractor.js +44 -7
- package/dist/catalog/catalogExtractor.js.map +1 -1
- package/dist/catalog/catalogLookup.d.ts +8 -0
- package/dist/catalog/catalogLookup.js +17 -0
- package/dist/catalog/catalogLookup.js.map +1 -1
- package/dist/catalog/types.d.ts +3 -3
- package/dist/catalog/types.js.map +1 -1
- package/dist/components/utils/feedbackUtils.d.ts +9 -4
- package/dist/components/utils/feedbackUtils.js +67 -34
- package/dist/components/utils/feedbackUtils.js.map +1 -1
- package/dist/core/AssessmentItemDefinition.js +35 -0
- package/dist/core/AssessmentItemDefinition.js.map +1 -1
- package/dist/core/ItemSession.d.ts +19 -1
- package/dist/core/ItemSession.js +12 -2
- package/dist/core/ItemSession.js.map +1 -1
- package/dist/core/Player.d.ts +41 -1
- package/dist/core/Player.js +216 -48
- package/dist/core/Player.js.map +1 -1
- package/dist/core/sanitizer.js +16 -3
- package/dist/core/sanitizer.js.map +1 -1
- package/dist/document/AssessmentItemDocument.d.ts +12 -5
- package/dist/document/AssessmentItemDocument.js +28 -19
- package/dist/document/AssessmentItemDocument.js.map +1 -1
- package/dist/document/contentPass.d.ts +17 -0
- package/dist/document/contentPass.js +40 -0
- package/dist/document/contentPass.js.map +1 -0
- package/dist/document/printedVariable.d.ts +35 -0
- package/dist/document/printedVariable.js +215 -0
- package/dist/document/printedVariable.js.map +1 -0
- package/dist/{element-class-BzATCyhV.js → element-class-D-kJi_w9.js} +3211 -2125
- package/dist/element-class-D-kJi_w9.js.map +1 -0
- package/dist/element-class.js +1 -1
- package/dist/element.js +1 -1
- package/dist/extraction/interactionAccessibility.d.ts +14 -0
- package/dist/extraction/interactionAccessibility.js +58 -0
- package/dist/extraction/interactionAccessibility.js.map +1 -0
- package/dist/extraction/interactionExtractionPipeline.d.ts +4 -1
- package/dist/extraction/interactionExtractionPipeline.js +7 -2
- package/dist/extraction/interactionExtractionPipeline.js.map +1 -1
- package/dist/extraction/utils.js +20 -1
- package/dist/extraction/utils.js.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/interactions/order/extractor.js +2 -0
- package/dist/interactions/order/extractor.js.map +1 -1
- package/dist/interactions/portable-custom/extractor.js +47 -11
- package/dist/interactions/portable-custom/extractor.js.map +1 -1
- package/dist/interactions/shared/types.d.ts +16 -0
- package/dist/interactions/shared/types.js.map +1 -1
- package/dist/pci/PciHost.d.ts +85 -43
- package/dist/pci/PciHost.js +229 -148
- package/dist/pci/PciHost.js.map +1 -1
- package/dist/pci/allowlistResolver.d.ts +10 -1
- package/dist/pci/allowlistResolver.js +43 -4
- package/dist/pci/allowlistResolver.js.map +1 -1
- package/dist/pci/amdLoader.d.ts +23 -0
- package/dist/pci/amdLoader.js +190 -0
- package/dist/pci/amdLoader.js.map +1 -0
- package/dist/pci/index.d.ts +14 -3
- package/dist/pci/index.js +8 -1
- package/dist/pci/index.js.map +1 -1
- package/dist/pci/moduleSession.d.ts +41 -0
- package/dist/pci/moduleSession.js +2 -0
- package/dist/pci/moduleSession.js.map +1 -0
- package/dist/pci/pageRealmSession.d.ts +49 -0
- package/dist/pci/pageRealmSession.js +193 -0
- package/dist/pci/pageRealmSession.js.map +1 -0
- package/dist/pci/qtiVariableJson.d.ts +7 -0
- package/dist/pci/qtiVariableJson.js +93 -0
- package/dist/pci/qtiVariableJson.js.map +1 -0
- package/dist/pci/registry.d.ts +15 -0
- package/dist/pci/registry.js +77 -0
- package/dist/pci/registry.js.map +1 -0
- package/dist/pci/resolutionConfig.d.ts +23 -0
- package/dist/pci/resolutionConfig.js +63 -0
- package/dist/pci/resolutionConfig.js.map +1 -0
- package/dist/pci/sandbox/SandboxedPciSession.d.ts +78 -0
- package/dist/pci/sandbox/SandboxedPciSession.js +332 -0
- package/dist/pci/sandbox/SandboxedPciSession.js.map +1 -0
- package/dist/pci/sandbox/iframeConnector.d.ts +13 -0
- package/dist/pci/sandbox/iframeConnector.js +94 -0
- package/dist/pci/sandbox/iframeConnector.js.map +1 -0
- package/dist/pci/sandbox/protocol.d.ts +117 -0
- package/dist/pci/sandbox/protocol.js +49 -0
- package/dist/pci/sandbox/protocol.js.map +1 -0
- package/dist/pci/types.d.ts +213 -30
- package/dist/pci/types.js +8 -1
- package/dist/pci/types.js.map +1 -1
- package/dist/pnp/applyPnp.d.ts +3 -4
- package/dist/pnp/applyPnp.js +54 -8
- package/dist/pnp/applyPnp.js.map +1 -1
- package/dist/pnp/parsePnpXml.d.ts +2 -2
- package/dist/pnp/parsePnpXml.js +146 -4
- package/dist/pnp/parsePnpXml.js.map +1 -1
- package/dist/pnp/types.d.ts +57 -0
- package/dist/pnp/types.js.map +1 -1
- package/dist/presentation/itemPresentationPlan.d.ts +12 -1
- package/dist/presentation/itemPresentationPlan.js +11 -3
- package/dist/presentation/itemPresentationPlan.js.map +1 -1
- package/dist/server.d.ts +5 -0
- package/dist/server.js.map +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js.map +1 -1
- package/package.json +6 -6
- package/dist/element-class-BzATCyhV.js.map +0 -1
|
@@ -12,9 +12,21 @@ import type { HtmlContent, QTIFileResponse } from '../../types/index.js';
|
|
|
12
12
|
* Uses node-html-parser's HTMLElement type directly
|
|
13
13
|
*/
|
|
14
14
|
export type QTIElement = HTMLElement;
|
|
15
|
+
/**
|
|
16
|
+
* The interaction's authored accessible name and description, resolved to text from its
|
|
17
|
+
* `aria-labelledby`, `aria-label`, `aria-describedby` and `aria-description`.
|
|
18
|
+
*/
|
|
19
|
+
export interface InteractionAccessibility {
|
|
20
|
+
label?: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
}
|
|
23
|
+
/** The read-aloud attributes authored on an interaction element, for its renderer's host. */
|
|
24
|
+
export type InteractionReadAloud = Partial<Record<'lang' | 'data-catalog-idref' | 'data-tts-suppress', string>>;
|
|
15
25
|
export interface BaseInteractionData<TType extends string = string> {
|
|
16
26
|
readonly type: TType;
|
|
17
27
|
readonly responseId: string;
|
|
28
|
+
readonly accessibility?: InteractionAccessibility;
|
|
29
|
+
readonly readAloud?: InteractionReadAloud;
|
|
18
30
|
}
|
|
19
31
|
/**
|
|
20
32
|
* An extractor payload after the delivery pipeline has attached its authoritative
|
|
@@ -95,6 +107,10 @@ export interface OrderInteractionData extends BaseInteractionData<'orderInteract
|
|
|
95
107
|
text: HtmlContent;
|
|
96
108
|
fixed?: boolean;
|
|
97
109
|
}>;
|
|
110
|
+
/** The authored `orientation` attribute: `vertical` (default) or `horizontal` */
|
|
111
|
+
orientation?: string;
|
|
112
|
+
/** CSS classes from the orderInteraction element (orientation and `qti-labels-*`) */
|
|
113
|
+
interactionClasses?: string[];
|
|
98
114
|
}
|
|
99
115
|
export interface AssociableChoice {
|
|
100
116
|
identifier: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/interactions/shared/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG","sourcesContent":["/**\n * Interaction type mappings for strongly-typed registry\n *\n * This file defines the complete type system for the plugin-based\n * interaction renderer registry, ensuring compile-time type safety.\n */\n\nimport type { HTMLElement } from 'node-html-parser';\nimport type { ExtractedPci } from '../../pci/types.js';\nimport type { HtmlContent, QTIFileResponse } from '../../types/index.js';\n\n/**\n * Type alias for parsed QTI XML elements\n * Uses node-html-parser's HTMLElement type directly\n */\nexport type QTIElement = HTMLElement;\n\nexport interface BaseInteractionData<TType extends string = string> {\n\treadonly type: TType;\n\treadonly responseId: string;\n}\n\n/**\n * An extractor payload after the delivery pipeline has attached its authoritative\n * renderer type and authored response identifier.\n *\n * Identity-looking properties in `TPayload` are deliberately omitted. The\n * pipeline applies the same rule at runtime by spreading payload first and\n * writing these two framework-owned fields last.\n */\nexport type DeliveredInteraction<\n\tTType extends string,\n\tTPayload extends object,\n> = Readonly<\n\tOmit<TPayload, keyof BaseInteractionData> & BaseInteractionData<TType>\n>;\n\nexport interface ChoiceInteractionData extends BaseInteractionData<'choiceInteraction'> {\n\tshuffle: boolean;\n\tmaxChoices: number;\n\tminChoices: number;\n\tprompt: HtmlContent | null;\n\tchoices: Array<{ identifier: string; text: HtmlContent; fixed?: boolean; classes?: string[] }>;\n\t/** CSS classes from the choiceInteraction element for custom renderer detection */\n\tinteractionClasses?: string[];\n\t/** Message shown when candidate exceeds maxChoices (data-max-selections-message) */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below minChoices (data-min-selections-message) */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface TextEntryInteractionData extends BaseInteractionData<'textEntryInteraction'> {\n\texpectedLength: number;\n\tpatternMask: string | null;\n\tplaceholderText: string;\n\tformat?: string;\n\t/** CSS classes from the textEntryInteraction element (e.g. qti-input-width-N) */\n\tinteractionClasses?: string[];\n\t/** Pattern mask validation message (data-patternmask-message) */\n\tpatternMaskMessage?: string | null;\n}\n\nexport interface ExtendedTextInteractionData extends BaseInteractionData<'extendedTextInteraction'> {\n\tcardinality: 'single' | 'multiple' | 'ordered' | 'record';\n\tbaseType?: string;\n\tbase: number;\n\tstringIdentifier?: string;\n\tminStrings: number;\n\t/** Zero means no authored upper bound. */\n\tmaxStrings: number;\n\texpectedLines: number;\n\texpectedLength: number;\n\tprompt: HtmlContent | null;\n\tplaceholderText: string;\n\tformat: string;\n\tpatternMask?: string | null;\n\tpatternMaskMessage?: string | null;\n\t/** CSS classes from the extendedTextInteraction element (e.g. qti-height-lines-N) */\n\tinteractionClasses?: string[];\n}\n\nexport interface InlineChoiceInteractionData extends BaseInteractionData<'inlineChoiceInteraction'> {\n\tshuffle: boolean;\n\t/** Placeholder label from the QTI <label> child element; shown as the unselected \"Select…\" option */\n\tlabel: string | null;\n\t/** Placeholder text from data-prompt attribute; alternative to <label> for dropdown default option */\n\tdataPrompt?: string | null;\n\tchoices: Array<{ identifier: string; text: string; fixed?: boolean }>;\n\t/** CSS classes from the inlineChoiceInteraction element (e.g. qti-input-width-N) */\n\tinteractionClasses?: string[];\n}\n\nexport interface OrderInteractionData extends BaseInteractionData<'orderInteraction'> {\n\tshuffle: boolean;\n\tminChoices: number;\n\tmaxChoices: number;\n\tprompt: HtmlContent | null;\n\tchoices: Array<{ identifier: string; text: HtmlContent; fixed?: boolean }>;\n}\n\nexport interface AssociableChoice {\n\tidentifier: string;\n\ttext: HtmlContent;\n\tmatchMax: number;\n\t/** Minimum number of times this choice must appear in the response (QTI matchMin) */\n\tmatchMin?: number;\n\t/** Pairing constraint: choice can only be paired with others sharing a group value (QTI matchGroup) */\n\tmatchGroup?: string[];\n\t/** CSS classes from the choice element for custom renderer detection */\n\tclasses?: string[];\n}\n\nexport interface MatchInteractionData extends BaseInteractionData<'matchInteraction'> {\n\tshuffle: boolean;\n\tmaxAssociations: number;\n\tminAssociations?: number;\n\tprompt: HtmlContent | null;\n\tsourceSet: AssociableChoice[];\n\ttargetSet: AssociableChoice[];\n\t/** CSS classes from the matchInteraction element (e.g. qti-choices-top, qti-match-tabular) */\n\tinteractionClasses?: string[];\n\t/** Message shown when candidate exceeds maxAssociations */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below minAssociations */\n\tminSelectionsMessage?: string | null;\n\t/** Label for first column header in tabular mode (data-qti-first-column-header) */\n\tfirstColumnHeader?: string | null;\n}\n\nexport interface AssociateInteractionData extends BaseInteractionData<'associateInteraction'> {\n\tshuffle: boolean;\n\tmaxAssociations: number;\n\tminAssociations?: number;\n\tprompt: HtmlContent | null;\n\tchoices: AssociableChoice[];\n}\n\nexport interface GapMatchInteractionData extends BaseInteractionData<'gapMatchInteraction'> {\n\tshuffle: boolean;\n\tprompt: HtmlContent | null;\n\tgapTexts: Array<{ identifier: string; text: string; matchMax: number; matchGroup?: string[]; inputWidth?: number }>;\n\tgaps: Array<{ identifier: string; index: number }>;\n\t/** Finalized HTML template containing `[GAP:identifier]` text markers. */\n\tpromptText: HtmlContent;\n\t/** CSS classes from the gapMatchInteraction element (e.g. qti-choices-top, qti-choices-bottom) */\n\tinteractionClasses?: string[];\n\t/** Width of the choice container in px (data-choices-container-width) */\n\tchoicesContainerWidth?: string | null;\n\t/** Message shown when candidate exceeds max associations */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below min associations */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface SliderInteractionData extends BaseInteractionData<'sliderInteraction'> {\n\tlowerBound: number;\n\tupperBound: number;\n\tstep: number;\n\torientation: string;\n\treverse: boolean;\n\tprompt: HtmlContent | null;\n}\n\nexport interface ImageData {\n\ttype: 'svg' | 'image';\n\tcontent?: HtmlContent;\n\tsrc?: string;\n\twidth: string;\n\theight: string;\n}\n\nexport interface HotspotChoice {\n\tidentifier: string;\n\tshape: string;\n\tcoords: string;\n\t/** Author-provided label for the hotspot; used as accessible aria-label */\n\thotspotLabel?: string;\n}\n\nexport interface HotspotInteractionData extends BaseInteractionData<'hotspotInteraction'> {\n\tmaxChoices: number;\n\tminChoices?: number;\n\tprompt: HtmlContent | null;\n\timageData: ImageData | null;\n\thotspotChoices: HotspotChoice[];\n\t/** CSS classes from the hotspotInteraction element (e.g. qti-selections-light, qti-selections-dark) */\n\tinteractionClasses?: string[];\n\t/** Message shown when candidate exceeds maxChoices */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below minChoices */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface AssociableHotspot {\n\tidentifier: string;\n\tshape: string;\n\tcoords: string;\n\tmatchMax: number;\n}\n\nexport interface GraphicGapMatchInteractionData extends BaseInteractionData<'graphicGapMatchInteraction'> {\n\tprompt: HtmlContent | null;\n\timageData: ImageData | null;\n\tmaxAssociations: number;\n\tgapTexts: Array<{ identifier: string; text: string; matchMax: number; matchGroup?: string[] }>;\n\t/** Image-based draggable labels (gapImg elements); rendered as <img> in the choice pool */\n\tgapImages: Array<{ identifier: string; src: string; alt: string; matchMax: number; matchGroup?: string[]; width?: number; height?: number }>;\n\thotspots: AssociableHotspot[];\n\t/** CSS classes from the graphicGapMatchInteraction element (e.g. qti-choices-top, qti-selections-dark) */\n\tinteractionClasses?: string[];\n\t/** Width of the choice container in px (data-choices-container-width) */\n\tchoicesContainerWidth?: string | null;\n\t/** Message shown when candidate exceeds max associations */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below min associations */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface UploadInteractionData extends BaseInteractionData<'uploadInteraction'> {\n\tprompt: HtmlContent | null;\n\t/** Allowed MIME types / extensions (vendor-dependent); empty = accept any */\n\tfileTypes: string[];\n\trawAttributes: Record<string, string>;\n}\n\nexport interface DrawingInteractionData extends BaseInteractionData<'drawingInteraction'> {\n\tprompt: HtmlContent | null;\n\t/** Optional background image/SVG to draw on top of */\n\timageData: ImageData | null;\n\trawAttributes: Record<string, string>;\n}\n\nexport interface CustomInteractionData extends BaseInteractionData<'customInteraction'> {\n\tprompt: HtmlContent | null;\n\trawAttributes: Record<string, string>;\n\t/** Outer XML snippet for debugging (best-effort) */\n\txml: string;\n}\n\n/** Canonical interaction data for QTI 2.x and 3.0 Portable Custom Interactions. */\nexport interface PortableCustomInteractionData\n\textends BaseInteractionData<'portableCustomInteraction'>,\n\t\tExtractedPci {}\n\nexport interface MediaElement {\n\ttype: 'audio' | 'video' | 'object';\n\tsrc: string;\n\tmimeType: string;\n\twidth?: number;\n\theight?: number;\n}\n\nexport interface MediaInteractionData extends BaseInteractionData<'mediaInteraction'> {\n\tprompt: HtmlContent | null;\n\tautostart: boolean;\n\tminPlays: number;\n\tmaxPlays: number; // 0 = unlimited\n\tloop: boolean;\n\tmediaElement: MediaElement;\n\t/** Whether the renderer should allow <object> embeds for this interaction (default false) */\n\tallowObjectEmbeds?: boolean;\n}\n\nexport interface HottextChoice {\n\tidentifier: string;\n\ttext: string;\n}\n\nexport interface HottextInteractionData extends BaseInteractionData<'hottextInteraction'> {\n\tprompt: HtmlContent | null;\n\tmaxChoices: number;\n\tminChoices: number;\n\tcontentHtml: HtmlContent;\n\thottextChoices: HottextChoice[];\n\t/** CSS classes from the hottextInteraction element (e.g. qti-input-control-hidden) */\n\tinteractionClasses?: string[];\n\t/** Message shown when candidate exceeds maxChoices */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below minChoices */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface Point {\n\tx: number;\n\ty: number;\n}\n\nexport interface SelectPointInteractionData extends BaseInteractionData<'selectPointInteraction'> {\n\tprompt: HtmlContent | null;\n\tmaxChoices: number;\n\tminChoices: number;\n\timageData: ImageData | null;\n}\n\nexport interface GraphicOrderChoice {\n\tidentifier: string;\n\tshape: string;\n\tcoords: string;\n\tlabel: string;\n}\n\nexport interface GraphicOrderInteractionData extends BaseInteractionData<'graphicOrderInteraction'> {\n\tprompt: HtmlContent | null;\n\timageData: ImageData | null;\n\thotspotChoices: GraphicOrderChoice[];\n}\n\nexport interface GraphicAssociateHotspot {\n\tidentifier: string;\n\tshape: string;\n\tcoords: string;\n\tmatchMax: number;\n\tlabel: string;\n\t/** Pairing constraint: hotspot can only be associated with others sharing a group value (QTI matchGroup) */\n\tmatchGroup?: string[];\n}\n\nexport interface GraphicAssociateInteractionData extends BaseInteractionData<'graphicAssociateInteraction'> {\n\tprompt: HtmlContent | null;\n\tmaxAssociations: number;\n\tminAssociations: number;\n\timageData: ImageData | null;\n\tassociableHotspots: GraphicAssociateHotspot[];\n}\n\nexport interface PositionObjectStage {\n\tidentifier: string;\n\tmatchMax: number;\n\tobjectData: {\n\t\ttype: 'image' | 'svg';\n\t\tsrc?: string;\n\t\tcontent?: HtmlContent;\n\t\twidth?: string;\n\t\theight?: string;\n\t} | null;\n\tlabel: string;\n}\n\nexport interface PositionObjectInteractionData extends BaseInteractionData<'positionObjectInteraction'> {\n\tprompt: HtmlContent | null;\n\tmaxChoices: number;\n\tminChoices: number;\n\tcenterPoint: boolean;\n\timageData: ImageData | null;\n\tpositionObjectStages: PositionObjectStage[];\n}\n\nexport interface EndAttemptInteractionData extends BaseInteractionData<'endAttemptInteraction'> {\n\tprompt: HtmlContent | null;\n\ttitle: string;\n\t/** Whether this interaction counts as an attempt (default: true) */\n\tcountAttempt: boolean;\n}\n\n/** Closed union of the interaction shapes supplied by the standard modules. */\nexport type StandardInteractionData =\n\t| ChoiceInteractionData\n\t| TextEntryInteractionData\n\t| ExtendedTextInteractionData\n\t| InlineChoiceInteractionData\n\t| OrderInteractionData\n\t| MatchInteractionData\n\t| AssociateInteractionData\n\t| GapMatchInteractionData\n\t| SliderInteractionData\n\t| HotspotInteractionData\n\t| GraphicGapMatchInteractionData\n\t| UploadInteractionData\n\t| DrawingInteractionData\n\t| CustomInteractionData\n\t| PortableCustomInteractionData\n\t| MediaInteractionData\n\t| HottextInteractionData\n\t| SelectPointInteractionData\n\t| GraphicOrderInteractionData\n\t| GraphicAssociateInteractionData\n\t| PositionObjectInteractionData\n\t| EndAttemptInteractionData;\n\n/**\n * QTI interaction type identifier\n * Extensible string type allows custom interaction types\n */\nexport type InteractionType = string;\n\n/**\n * Map interaction types to their data structures\n * TypeScript will ensure registrations use the correct data type\n */\nexport interface InteractionDataMap {\n\tchoiceInteraction: ChoiceInteractionData;\n\ttextEntryInteraction: TextEntryInteractionData;\n\textendedTextInteraction: ExtendedTextInteractionData;\n\tinlineChoiceInteraction: InlineChoiceInteractionData;\n\torderInteraction: OrderInteractionData;\n\tmatchInteraction: MatchInteractionData;\n\tassociateInteraction: AssociateInteractionData;\n\tgapMatchInteraction: GapMatchInteractionData;\n\tsliderInteraction: SliderInteractionData;\n\thotspotInteraction: HotspotInteractionData;\n\tgraphicGapMatchInteraction: GraphicGapMatchInteractionData;\n\tuploadInteraction: UploadInteractionData;\n\tdrawingInteraction: DrawingInteractionData;\n\tcustomInteraction: CustomInteractionData;\n\tportableCustomInteraction: PortableCustomInteractionData;\n\tmediaInteraction: MediaInteractionData;\n\thottextInteraction: HottextInteractionData;\n\tselectPointInteraction: SelectPointInteractionData;\n\tgraphicOrderInteraction: GraphicOrderInteractionData;\n\tgraphicAssociateInteraction: GraphicAssociateInteractionData;\n\tpositionObjectInteraction: PositionObjectInteractionData;\n\tendAttemptInteraction: EndAttemptInteractionData;\n}\n\n/**\n * Map interaction types to their response value types\n * Ensures getValue/setValue use the correct types\n */\nexport interface InteractionValueMap {\n\tchoiceInteraction: string | string[];\n\ttextEntryInteraction: string;\n\textendedTextInteraction: string;\n\tinlineChoiceInteraction: string;\n\torderInteraction: string[];\n\tmatchInteraction: Record<string, string>;\n\tassociateInteraction: Array<[string, string]>;\n\tgapMatchInteraction: Record<string, string>;\n\tsliderInteraction: number;\n\thotspotInteraction: string[];\n\tgraphicGapMatchInteraction: Record<string, string>;\n\tuploadInteraction: QTIFileResponse | null;\n\tdrawingInteraction: string;\n\tcustomInteraction: any;\n\tportableCustomInteraction: unknown;\n\tmediaInteraction: any;\n\thottextInteraction: string[];\n\tselectPointInteraction: Array<{ x: number; y: number }>;\n\tgraphicOrderInteraction: string[];\n\tgraphicAssociateInteraction: Array<[string, string]>;\n\tpositionObjectInteraction: Record<string, { x: number; y: number }>;\n\tendAttemptInteraction: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/interactions/shared/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG","sourcesContent":["/**\n * Interaction type mappings for strongly-typed registry\n *\n * This file defines the complete type system for the plugin-based\n * interaction renderer registry, ensuring compile-time type safety.\n */\n\nimport type { HTMLElement } from 'node-html-parser';\nimport type { ExtractedPci } from '../../pci/types.js';\nimport type { HtmlContent, QTIFileResponse } from '../../types/index.js';\n\n/**\n * Type alias for parsed QTI XML elements\n * Uses node-html-parser's HTMLElement type directly\n */\nexport type QTIElement = HTMLElement;\n\n/**\n * The interaction's authored accessible name and description, resolved to text from its\n * `aria-labelledby`, `aria-label`, `aria-describedby` and `aria-description`.\n */\nexport interface InteractionAccessibility {\n\tlabel?: string;\n\tdescription?: string;\n}\n\n/** The read-aloud attributes authored on an interaction element, for its renderer's host. */\nexport type InteractionReadAloud = Partial<Record<'lang' | 'data-catalog-idref' | 'data-tts-suppress', string>>;\n\nexport interface BaseInteractionData<TType extends string = string> {\n\treadonly type: TType;\n\treadonly responseId: string;\n\treadonly accessibility?: InteractionAccessibility;\n\treadonly readAloud?: InteractionReadAloud;\n}\n\n/**\n * An extractor payload after the delivery pipeline has attached its authoritative\n * renderer type and authored response identifier.\n *\n * Identity-looking properties in `TPayload` are deliberately omitted. The\n * pipeline applies the same rule at runtime by spreading payload first and\n * writing these two framework-owned fields last.\n */\nexport type DeliveredInteraction<\n\tTType extends string,\n\tTPayload extends object,\n> = Readonly<\n\tOmit<TPayload, keyof BaseInteractionData> & BaseInteractionData<TType>\n>;\n\nexport interface ChoiceInteractionData extends BaseInteractionData<'choiceInteraction'> {\n\tshuffle: boolean;\n\tmaxChoices: number;\n\tminChoices: number;\n\tprompt: HtmlContent | null;\n\tchoices: Array<{ identifier: string; text: HtmlContent; fixed?: boolean; classes?: string[] }>;\n\t/** CSS classes from the choiceInteraction element for custom renderer detection */\n\tinteractionClasses?: string[];\n\t/** Message shown when candidate exceeds maxChoices (data-max-selections-message) */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below minChoices (data-min-selections-message) */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface TextEntryInteractionData extends BaseInteractionData<'textEntryInteraction'> {\n\texpectedLength: number;\n\tpatternMask: string | null;\n\tplaceholderText: string;\n\tformat?: string;\n\t/** CSS classes from the textEntryInteraction element (e.g. qti-input-width-N) */\n\tinteractionClasses?: string[];\n\t/** Pattern mask validation message (data-patternmask-message) */\n\tpatternMaskMessage?: string | null;\n}\n\nexport interface ExtendedTextInteractionData extends BaseInteractionData<'extendedTextInteraction'> {\n\tcardinality: 'single' | 'multiple' | 'ordered' | 'record';\n\tbaseType?: string;\n\tbase: number;\n\tstringIdentifier?: string;\n\tminStrings: number;\n\t/** Zero means no authored upper bound. */\n\tmaxStrings: number;\n\texpectedLines: number;\n\texpectedLength: number;\n\tprompt: HtmlContent | null;\n\tplaceholderText: string;\n\tformat: string;\n\tpatternMask?: string | null;\n\tpatternMaskMessage?: string | null;\n\t/** CSS classes from the extendedTextInteraction element (e.g. qti-height-lines-N) */\n\tinteractionClasses?: string[];\n}\n\nexport interface InlineChoiceInteractionData extends BaseInteractionData<'inlineChoiceInteraction'> {\n\tshuffle: boolean;\n\t/** Placeholder label from the QTI <label> child element; shown as the unselected \"Select…\" option */\n\tlabel: string | null;\n\t/** Placeholder text from data-prompt attribute; alternative to <label> for dropdown default option */\n\tdataPrompt?: string | null;\n\tchoices: Array<{ identifier: string; text: string; fixed?: boolean }>;\n\t/** CSS classes from the inlineChoiceInteraction element (e.g. qti-input-width-N) */\n\tinteractionClasses?: string[];\n}\n\nexport interface OrderInteractionData extends BaseInteractionData<'orderInteraction'> {\n\tshuffle: boolean;\n\tminChoices: number;\n\tmaxChoices: number;\n\tprompt: HtmlContent | null;\n\tchoices: Array<{ identifier: string; text: HtmlContent; fixed?: boolean }>;\n\t/** The authored `orientation` attribute: `vertical` (default) or `horizontal` */\n\torientation?: string;\n\t/** CSS classes from the orderInteraction element (orientation and `qti-labels-*`) */\n\tinteractionClasses?: string[];\n}\n\nexport interface AssociableChoice {\n\tidentifier: string;\n\ttext: HtmlContent;\n\tmatchMax: number;\n\t/** Minimum number of times this choice must appear in the response (QTI matchMin) */\n\tmatchMin?: number;\n\t/** Pairing constraint: choice can only be paired with others sharing a group value (QTI matchGroup) */\n\tmatchGroup?: string[];\n\t/** CSS classes from the choice element for custom renderer detection */\n\tclasses?: string[];\n}\n\nexport interface MatchInteractionData extends BaseInteractionData<'matchInteraction'> {\n\tshuffle: boolean;\n\tmaxAssociations: number;\n\tminAssociations?: number;\n\tprompt: HtmlContent | null;\n\tsourceSet: AssociableChoice[];\n\ttargetSet: AssociableChoice[];\n\t/** CSS classes from the matchInteraction element (e.g. qti-choices-top, qti-match-tabular) */\n\tinteractionClasses?: string[];\n\t/** Message shown when candidate exceeds maxAssociations */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below minAssociations */\n\tminSelectionsMessage?: string | null;\n\t/** Label for first column header in tabular mode (data-qti-first-column-header) */\n\tfirstColumnHeader?: string | null;\n}\n\nexport interface AssociateInteractionData extends BaseInteractionData<'associateInteraction'> {\n\tshuffle: boolean;\n\tmaxAssociations: number;\n\tminAssociations?: number;\n\tprompt: HtmlContent | null;\n\tchoices: AssociableChoice[];\n}\n\nexport interface GapMatchInteractionData extends BaseInteractionData<'gapMatchInteraction'> {\n\tshuffle: boolean;\n\tprompt: HtmlContent | null;\n\tgapTexts: Array<{ identifier: string; text: string; matchMax: number; matchGroup?: string[]; inputWidth?: number }>;\n\tgaps: Array<{ identifier: string; index: number }>;\n\t/** Finalized HTML template containing `[GAP:identifier]` text markers. */\n\tpromptText: HtmlContent;\n\t/** CSS classes from the gapMatchInteraction element (e.g. qti-choices-top, qti-choices-bottom) */\n\tinteractionClasses?: string[];\n\t/** Width of the choice container in px (data-choices-container-width) */\n\tchoicesContainerWidth?: string | null;\n\t/** Message shown when candidate exceeds max associations */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below min associations */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface SliderInteractionData extends BaseInteractionData<'sliderInteraction'> {\n\tlowerBound: number;\n\tupperBound: number;\n\tstep: number;\n\torientation: string;\n\treverse: boolean;\n\tprompt: HtmlContent | null;\n}\n\nexport interface ImageData {\n\ttype: 'svg' | 'image';\n\tcontent?: HtmlContent;\n\tsrc?: string;\n\twidth: string;\n\theight: string;\n}\n\nexport interface HotspotChoice {\n\tidentifier: string;\n\tshape: string;\n\tcoords: string;\n\t/** Author-provided label for the hotspot; used as accessible aria-label */\n\thotspotLabel?: string;\n}\n\nexport interface HotspotInteractionData extends BaseInteractionData<'hotspotInteraction'> {\n\tmaxChoices: number;\n\tminChoices?: number;\n\tprompt: HtmlContent | null;\n\timageData: ImageData | null;\n\thotspotChoices: HotspotChoice[];\n\t/** CSS classes from the hotspotInteraction element (e.g. qti-selections-light, qti-selections-dark) */\n\tinteractionClasses?: string[];\n\t/** Message shown when candidate exceeds maxChoices */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below minChoices */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface AssociableHotspot {\n\tidentifier: string;\n\tshape: string;\n\tcoords: string;\n\tmatchMax: number;\n}\n\nexport interface GraphicGapMatchInteractionData extends BaseInteractionData<'graphicGapMatchInteraction'> {\n\tprompt: HtmlContent | null;\n\timageData: ImageData | null;\n\tmaxAssociations: number;\n\tgapTexts: Array<{ identifier: string; text: string; matchMax: number; matchGroup?: string[] }>;\n\t/** Image-based draggable labels (gapImg elements); rendered as <img> in the choice pool */\n\tgapImages: Array<{ identifier: string; src: string; alt: string; matchMax: number; matchGroup?: string[]; width?: number; height?: number }>;\n\thotspots: AssociableHotspot[];\n\t/** CSS classes from the graphicGapMatchInteraction element (e.g. qti-choices-top, qti-selections-dark) */\n\tinteractionClasses?: string[];\n\t/** Width of the choice container in px (data-choices-container-width) */\n\tchoicesContainerWidth?: string | null;\n\t/** Message shown when candidate exceeds max associations */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below min associations */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface UploadInteractionData extends BaseInteractionData<'uploadInteraction'> {\n\tprompt: HtmlContent | null;\n\t/** Allowed MIME types / extensions (vendor-dependent); empty = accept any */\n\tfileTypes: string[];\n\trawAttributes: Record<string, string>;\n}\n\nexport interface DrawingInteractionData extends BaseInteractionData<'drawingInteraction'> {\n\tprompt: HtmlContent | null;\n\t/** Optional background image/SVG to draw on top of */\n\timageData: ImageData | null;\n\trawAttributes: Record<string, string>;\n}\n\nexport interface CustomInteractionData extends BaseInteractionData<'customInteraction'> {\n\tprompt: HtmlContent | null;\n\trawAttributes: Record<string, string>;\n\t/** Outer XML snippet for debugging (best-effort) */\n\txml: string;\n}\n\n/** Canonical interaction data for QTI 2.x and 3.0 Portable Custom Interactions. */\nexport interface PortableCustomInteractionData\n\textends BaseInteractionData<'portableCustomInteraction'>,\n\t\tExtractedPci {}\n\nexport interface MediaElement {\n\ttype: 'audio' | 'video' | 'object';\n\tsrc: string;\n\tmimeType: string;\n\twidth?: number;\n\theight?: number;\n}\n\nexport interface MediaInteractionData extends BaseInteractionData<'mediaInteraction'> {\n\tprompt: HtmlContent | null;\n\tautostart: boolean;\n\tminPlays: number;\n\tmaxPlays: number; // 0 = unlimited\n\tloop: boolean;\n\tmediaElement: MediaElement;\n\t/** Whether the renderer should allow <object> embeds for this interaction (default false) */\n\tallowObjectEmbeds?: boolean;\n}\n\nexport interface HottextChoice {\n\tidentifier: string;\n\ttext: string;\n}\n\nexport interface HottextInteractionData extends BaseInteractionData<'hottextInteraction'> {\n\tprompt: HtmlContent | null;\n\tmaxChoices: number;\n\tminChoices: number;\n\tcontentHtml: HtmlContent;\n\thottextChoices: HottextChoice[];\n\t/** CSS classes from the hottextInteraction element (e.g. qti-input-control-hidden) */\n\tinteractionClasses?: string[];\n\t/** Message shown when candidate exceeds maxChoices */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below minChoices */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface Point {\n\tx: number;\n\ty: number;\n}\n\nexport interface SelectPointInteractionData extends BaseInteractionData<'selectPointInteraction'> {\n\tprompt: HtmlContent | null;\n\tmaxChoices: number;\n\tminChoices: number;\n\timageData: ImageData | null;\n}\n\nexport interface GraphicOrderChoice {\n\tidentifier: string;\n\tshape: string;\n\tcoords: string;\n\tlabel: string;\n}\n\nexport interface GraphicOrderInteractionData extends BaseInteractionData<'graphicOrderInteraction'> {\n\tprompt: HtmlContent | null;\n\timageData: ImageData | null;\n\thotspotChoices: GraphicOrderChoice[];\n}\n\nexport interface GraphicAssociateHotspot {\n\tidentifier: string;\n\tshape: string;\n\tcoords: string;\n\tmatchMax: number;\n\tlabel: string;\n\t/** Pairing constraint: hotspot can only be associated with others sharing a group value (QTI matchGroup) */\n\tmatchGroup?: string[];\n}\n\nexport interface GraphicAssociateInteractionData extends BaseInteractionData<'graphicAssociateInteraction'> {\n\tprompt: HtmlContent | null;\n\tmaxAssociations: number;\n\tminAssociations: number;\n\timageData: ImageData | null;\n\tassociableHotspots: GraphicAssociateHotspot[];\n}\n\nexport interface PositionObjectStage {\n\tidentifier: string;\n\tmatchMax: number;\n\tobjectData: {\n\t\ttype: 'image' | 'svg';\n\t\tsrc?: string;\n\t\tcontent?: HtmlContent;\n\t\twidth?: string;\n\t\theight?: string;\n\t} | null;\n\tlabel: string;\n}\n\nexport interface PositionObjectInteractionData extends BaseInteractionData<'positionObjectInteraction'> {\n\tprompt: HtmlContent | null;\n\tmaxChoices: number;\n\tminChoices: number;\n\tcenterPoint: boolean;\n\timageData: ImageData | null;\n\tpositionObjectStages: PositionObjectStage[];\n}\n\nexport interface EndAttemptInteractionData extends BaseInteractionData<'endAttemptInteraction'> {\n\tprompt: HtmlContent | null;\n\ttitle: string;\n\t/** Whether this interaction counts as an attempt (default: true) */\n\tcountAttempt: boolean;\n}\n\n/** Closed union of the interaction shapes supplied by the standard modules. */\nexport type StandardInteractionData =\n\t| ChoiceInteractionData\n\t| TextEntryInteractionData\n\t| ExtendedTextInteractionData\n\t| InlineChoiceInteractionData\n\t| OrderInteractionData\n\t| MatchInteractionData\n\t| AssociateInteractionData\n\t| GapMatchInteractionData\n\t| SliderInteractionData\n\t| HotspotInteractionData\n\t| GraphicGapMatchInteractionData\n\t| UploadInteractionData\n\t| DrawingInteractionData\n\t| CustomInteractionData\n\t| PortableCustomInteractionData\n\t| MediaInteractionData\n\t| HottextInteractionData\n\t| SelectPointInteractionData\n\t| GraphicOrderInteractionData\n\t| GraphicAssociateInteractionData\n\t| PositionObjectInteractionData\n\t| EndAttemptInteractionData;\n\n/**\n * QTI interaction type identifier\n * Extensible string type allows custom interaction types\n */\nexport type InteractionType = string;\n\n/**\n * Map interaction types to their data structures\n * TypeScript will ensure registrations use the correct data type\n */\nexport interface InteractionDataMap {\n\tchoiceInteraction: ChoiceInteractionData;\n\ttextEntryInteraction: TextEntryInteractionData;\n\textendedTextInteraction: ExtendedTextInteractionData;\n\tinlineChoiceInteraction: InlineChoiceInteractionData;\n\torderInteraction: OrderInteractionData;\n\tmatchInteraction: MatchInteractionData;\n\tassociateInteraction: AssociateInteractionData;\n\tgapMatchInteraction: GapMatchInteractionData;\n\tsliderInteraction: SliderInteractionData;\n\thotspotInteraction: HotspotInteractionData;\n\tgraphicGapMatchInteraction: GraphicGapMatchInteractionData;\n\tuploadInteraction: UploadInteractionData;\n\tdrawingInteraction: DrawingInteractionData;\n\tcustomInteraction: CustomInteractionData;\n\tportableCustomInteraction: PortableCustomInteractionData;\n\tmediaInteraction: MediaInteractionData;\n\thottextInteraction: HottextInteractionData;\n\tselectPointInteraction: SelectPointInteractionData;\n\tgraphicOrderInteraction: GraphicOrderInteractionData;\n\tgraphicAssociateInteraction: GraphicAssociateInteractionData;\n\tpositionObjectInteraction: PositionObjectInteractionData;\n\tendAttemptInteraction: EndAttemptInteractionData;\n}\n\n/**\n * Map interaction types to their response value types\n * Ensures getValue/setValue use the correct types\n */\nexport interface InteractionValueMap {\n\tchoiceInteraction: string | string[];\n\ttextEntryInteraction: string;\n\textendedTextInteraction: string;\n\tinlineChoiceInteraction: string;\n\torderInteraction: string[];\n\tmatchInteraction: Record<string, string>;\n\tassociateInteraction: Array<[string, string]>;\n\tgapMatchInteraction: Record<string, string>;\n\tsliderInteraction: number;\n\thotspotInteraction: string[];\n\tgraphicGapMatchInteraction: Record<string, string>;\n\tuploadInteraction: QTIFileResponse | null;\n\tdrawingInteraction: string;\n\tcustomInteraction: any;\n\tportableCustomInteraction: unknown;\n\tmediaInteraction: any;\n\thottextInteraction: string[];\n\tselectPointInteraction: Array<{ x: number; y: number }>;\n\tgraphicOrderInteraction: string[];\n\tgraphicAssociateInteraction: Array<[string, string]>;\n\tpositionObjectInteraction: Record<string, { x: number; y: number }>;\n\tendAttemptInteraction: boolean;\n}\n"]}
|
package/dist/pci/PciHost.d.ts
CHANGED
|
@@ -1,26 +1,46 @@
|
|
|
1
1
|
import type { ExtractedPci, PciHostController, PciHostOptions } from './types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Loads, initializes, and manages the lifecycle of a single PCI module
|
|
3
|
+
* Loads, initializes, and manages the lifecycle of a single PCI module under the
|
|
4
|
+
* QTI 3.0 §6.1 contract.
|
|
5
|
+
*
|
|
6
|
+
* The module-facing contract is engine-independent: a module registers itself
|
|
7
|
+
* against `qtiCustomInteractionContext` as its code evaluates, instantiation
|
|
8
|
+
* goes through the registered `getInstance(dom, configuration, state)` factory
|
|
9
|
+
* — state in, `getResponse()` / `getState()` out, no setter — and an
|
|
10
|
+
* authoritative response change re-instantiates the module. What the host
|
|
11
|
+
* chooses is *where that code runs*: by default the page realm behind a host
|
|
12
|
+
* resolver (`moduleResolver`), or, with `sandbox` configured, a cross-origin
|
|
13
|
+
* runner frame whose document has an opaque origin. The response-ownership
|
|
14
|
+
* state machine below is shared by both engines; only the execution backend
|
|
15
|
+
* (`PciModuleSession`) differs.
|
|
4
16
|
*
|
|
5
17
|
* Usage:
|
|
6
18
|
* const host = new PciHost(extractedData, { baseUrl, moduleResolver });
|
|
7
19
|
* await host.load();
|
|
8
20
|
* host.initialize(domNode);
|
|
9
|
-
* host.getResponse(); //
|
|
21
|
+
* host.getResponse(); // current response, in the player's runtime value shape
|
|
10
22
|
* host.destroy(); // cleanup on player teardown
|
|
11
23
|
*/
|
|
12
24
|
export declare class PciHost implements PciHostController {
|
|
13
25
|
private readonly data;
|
|
14
26
|
private readonly baseUrl;
|
|
15
27
|
private readonly moduleResolver;
|
|
16
|
-
private
|
|
28
|
+
private readonly sandboxConfig;
|
|
29
|
+
private readonly responseDeclaration;
|
|
30
|
+
private readonly statusSource;
|
|
31
|
+
private readonly registry;
|
|
32
|
+
private readonly session;
|
|
33
|
+
private instance;
|
|
34
|
+
private mountNode;
|
|
35
|
+
private loaded;
|
|
17
36
|
private destroyed;
|
|
18
37
|
private loadGeneration;
|
|
19
38
|
private _response;
|
|
20
39
|
private _hasResponse;
|
|
21
40
|
/**
|
|
22
|
-
* True once a mounted module has reported a response
|
|
23
|
-
* is the source of truth and
|
|
41
|
+
* True once a mounted module has reported a response (through its own getResponse
|
|
42
|
+
* captured at `onready`/`ondone`). While set, the module is the source of truth and
|
|
43
|
+
* `offerResponse()` will not overwrite it.
|
|
24
44
|
*/
|
|
25
45
|
private _moduleOwnsResponse;
|
|
26
46
|
/**
|
|
@@ -29,12 +49,18 @@ export declare class PciHost implements PciHostController {
|
|
|
29
49
|
* `getResponse()` must report the held one.
|
|
30
50
|
*/
|
|
31
51
|
private _restorePending;
|
|
52
|
+
/** The module's own state snapshot, seeded back at the next `getInstance`. */
|
|
53
|
+
private _instanceState;
|
|
54
|
+
/** The held value the current instantiation was seeded with, for no-op echo detection. */
|
|
55
|
+
private _lastSeed;
|
|
32
56
|
private readonly _responseChangeListeners;
|
|
33
57
|
private readonly _remountRequestListeners;
|
|
58
|
+
private readonly _errorListeners;
|
|
34
59
|
constructor(data: ExtractedPci, options?: PciHostOptions | string);
|
|
35
60
|
/**
|
|
36
|
-
* Register a callback to fire when the PCI's response changes.
|
|
37
|
-
*
|
|
61
|
+
* Register a callback to fire when the PCI's response changes. The player calls
|
|
62
|
+
* this to wire the PCI into its internal response map. Values arrive in the
|
|
63
|
+
* player's runtime shape; QTI variable JSON conversion happened at the boundary.
|
|
38
64
|
*/
|
|
39
65
|
onResponseChange(callback: (responseId: string, value: unknown) => void): () => void;
|
|
40
66
|
/**
|
|
@@ -43,31 +69,44 @@ export declare class PciHost implements PciHostController {
|
|
|
43
69
|
*
|
|
44
70
|
* The renderer owns the DOM scaffold and its sanitization, so it performs the
|
|
45
71
|
* rebuild: reset the sanitized markup into the mount node, then call
|
|
46
|
-
* `remount(node)`. A host with no renderer wired here
|
|
47
|
-
*
|
|
72
|
+
* `remount(node)`. A host with no renderer wired here re-instantiates the
|
|
73
|
+
* module on the last mount node itself.
|
|
48
74
|
*/
|
|
49
75
|
onRemountRequest(callback: () => void): () => void;
|
|
50
76
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
77
|
+
* Register a callback for asynchronous engine failures: the sandboxed
|
|
78
|
+
* engine's frame handshake, in-frame module load, or instance errors. The
|
|
79
|
+
* page-realm engine rejects `load()` instead and never uses this channel.
|
|
80
|
+
*/
|
|
81
|
+
onError(callback: (error: Error) => void): () => void;
|
|
82
|
+
/**
|
|
83
|
+
* Bring the module's execution backend up: page-realm hosts evaluate the
|
|
84
|
+
* module (primary path, then fallback, through the AMD loader for
|
|
85
|
+
* multi-module declarations) and adopt its registration; the sandboxed
|
|
86
|
+
* engine prepares the init payload and defers the module load to the runner
|
|
87
|
+
* frame, whose failures surface through `onError`. Throws PciLoadError when
|
|
88
|
+
* both page-realm paths fail or the module never registers.
|
|
53
89
|
*/
|
|
54
90
|
load(): Promise<void>;
|
|
55
91
|
/**
|
|
56
|
-
*
|
|
57
|
-
* Must be called after
|
|
92
|
+
* Instantiate the PCI inside the given DOM element through the registered
|
|
93
|
+
* `getInstance` factory, seeding it with the held state. Must be called after
|
|
94
|
+
* load() resolves. The sandboxed engine mounts its runner frame here instead:
|
|
95
|
+
* the frame element replaces the scaffold's markup, because the module renders
|
|
96
|
+
* inside the frame, not on the page.
|
|
58
97
|
*/
|
|
59
98
|
initialize(dom: HTMLElement): void;
|
|
60
|
-
/** Return the current response value
|
|
99
|
+
/** Return the current response value, in the player's runtime value shape. */
|
|
61
100
|
getResponse(): unknown;
|
|
101
|
+
/** The mounted module's state snapshot, when it exposes `getState()`. */
|
|
102
|
+
getState(): unknown;
|
|
62
103
|
/**
|
|
63
104
|
* Offer a response the player believes to be current.
|
|
64
105
|
*
|
|
65
|
-
* Declined once a mounted module has reported a response of its own.
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* the module derives from it. Use `restore()` when the player's value must
|
|
70
|
-
* win regardless.
|
|
106
|
+
* Declined once a mounted module has reported a response of its own. Under the
|
|
107
|
+
* spec contract there is no setter, so an accepted offer before any report is
|
|
108
|
+
* either held for the next instantiation or, when the value differs from what
|
|
109
|
+
* the mounted module was seeded with, applied by re-instantiating it in place.
|
|
71
110
|
*
|
|
72
111
|
* @returns `false` when the module retained ownership and the value was not applied.
|
|
73
112
|
*/
|
|
@@ -76,41 +115,44 @@ export declare class PciHost implements PciHostController {
|
|
|
76
115
|
* Authoritatively replace the response, discarding in-progress candidate
|
|
77
116
|
* state and returning ownership to the player.
|
|
78
117
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* With no rebuild path wired, the value is pushed into the module directly.
|
|
87
|
-
* That mutates rather than discards candidate state, which is all a host
|
|
88
|
-
* without a scaffold owner can do, and it keeps reset-to-default and session
|
|
89
|
-
* restore effective for consumers driving `PciHost` themselves. Before mount,
|
|
90
|
-
* the value is held and applied by `initialize()`.
|
|
118
|
+
* "Discard candidate state" is re-instantiation: state is injected at
|
|
119
|
+
* `getInstance` and the contract offers no setter. Where a renderer is wired
|
|
120
|
+
* to `onRemountRequest` it rebuilds through a scaffold reset; otherwise this
|
|
121
|
+
* host re-instantiates the module on the last mount node itself. Until the
|
|
122
|
+
* rebuild lands, `getResponse()` reports the restored value rather than the
|
|
123
|
+
* module's superseded one.
|
|
91
124
|
*/
|
|
92
125
|
restore(value: unknown): void;
|
|
93
126
|
/**
|
|
94
127
|
* Rebuild the module in place from the currently held response.
|
|
95
128
|
*
|
|
96
129
|
* The caller must reset the sanitized DOM scaffold into `dom` first: this
|
|
97
|
-
* discards the previous module instance, resolves
|
|
98
|
-
*
|
|
130
|
+
* discards the previous module instance, re-resolves the registration, and
|
|
131
|
+
* instantiates it with the held state.
|
|
99
132
|
*/
|
|
100
133
|
remount(dom: HTMLElement): Promise<void>;
|
|
101
|
-
/**
|
|
134
|
+
/**
|
|
135
|
+
* Nudge the module out of interaction, for hosts whose module exposes the
|
|
136
|
+
* optional `disable` method. Conformant modules read their fixed
|
|
137
|
+
* `configuration.status` instead.
|
|
138
|
+
*/
|
|
102
139
|
disable(): void;
|
|
103
|
-
/**
|
|
140
|
+
/** The counterpart of `disable()`, for modules that expose it. */
|
|
104
141
|
enable(): void;
|
|
105
142
|
/** Tear down the PCI and release all resources. */
|
|
106
143
|
destroy(): void;
|
|
107
|
-
private
|
|
108
|
-
private resolveUrl;
|
|
109
|
-
private isCurrentLoad;
|
|
110
|
-
private adoptResolvedModule;
|
|
144
|
+
private destroyInstance;
|
|
111
145
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
146
|
+
* Re-instantiate the current module on the last mount node, discarding the
|
|
147
|
+
* previous instance. The DOM scaffold is not reset here — that is the
|
|
148
|
+
* renderer's job, and this path exists for hosts that wired none.
|
|
114
149
|
*/
|
|
115
|
-
private
|
|
150
|
+
private rebuildInPlace;
|
|
151
|
+
private buildConfiguration;
|
|
152
|
+
/** Take the mounted module's response as its own report and publish it. */
|
|
153
|
+
private captureInstanceResponse;
|
|
154
|
+
/** The held response as the `state` a fresh instantiation receives. */
|
|
155
|
+
private seedValue;
|
|
156
|
+
private valuesEqual;
|
|
157
|
+
private isCurrentLoad;
|
|
116
158
|
}
|