@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
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The player's one clone/freeze family.
|
|
3
|
+
*
|
|
4
|
+
* Everything the player snapshots (session views, transitions, serialized
|
|
5
|
+
* state, delivered interaction data, definition configuration, presentation
|
|
6
|
+
* plans) goes through these helpers, so the treatment of the shapes that make
|
|
7
|
+
* deep-copying hazardous is defined once:
|
|
8
|
+
*
|
|
9
|
+
* - Plain objects and arrays are structurally deep-copied.
|
|
10
|
+
* - ArrayBuffers and typed arrays are copied and never frozen: a response's
|
|
11
|
+
* drawing `imageData` (`Uint8ClampedArray`) cannot be frozen — `Object.freeze`
|
|
12
|
+
* throws on a non-empty integer-indexed exotic object — and callers must stay
|
|
13
|
+
* able to read it after `state()`, serialize and restore.
|
|
14
|
+
* - TrustedHTML, `File`, `Blob` and every other non-plain object keep their
|
|
15
|
+
* identity as terminal leaves. `structuredClone` would throw `DataCloneError`
|
|
16
|
+
* on a TrustedHTML value, so presentation and extraction data — which carry
|
|
17
|
+
* TrustedHTML once a Trusted Types policy is configured — are never handed to
|
|
18
|
+
* it; a host-owned object a plugin supplied deliberately must survive
|
|
19
|
+
* delivery as the same object.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Structural deep copy of plain data. Typed arrays and buffers are copied;
|
|
23
|
+
* non-plain objects keep their identity; nothing is frozen.
|
|
24
|
+
*/
|
|
25
|
+
export declare function cloneValue<T>(value: T): T;
|
|
26
|
+
/**
|
|
27
|
+
* In-place deep freeze of a data graph. Plain objects and arrays are frozen;
|
|
28
|
+
* non-plain leaves (TrustedHTML, File, Blob, typed arrays, host objects) are
|
|
29
|
+
* returned untouched — freezing a browser-owned object can throw and freezing
|
|
30
|
+
* a typed array always would. An already-frozen node short-circuits its subtree.
|
|
31
|
+
*/
|
|
32
|
+
export declare function deepFreezeInPlace<T>(value: T): T;
|
|
33
|
+
/**
|
|
34
|
+
* Clone and freeze plain data without mutating values owned by the caller or a
|
|
35
|
+
* PCI module: `cloneValue`'s copy, deeply frozen.
|
|
36
|
+
*/
|
|
37
|
+
export declare function frozenSnapshot<T>(value: T): T;
|
|
38
|
+
/**
|
|
39
|
+
* A hand-out copy of an ALREADY deeply frozen snapshot for one recipient. The frozen plain
|
|
40
|
+
* structure is shared as-is — freezing makes it unobservable to mutation — but every
|
|
41
|
+
* typed-array leaf, which the platform cannot freeze, is re-copied, so recipients never
|
|
42
|
+
* share the snapshot's mutable unfrozen data (listeners pin that isolation, see
|
|
43
|
+
* tests/core/assessment-item-definition.test.ts "detaches drawing response data"). Non-plain
|
|
44
|
+
* leaves keep their identity, as everywhere in this family. A snapshot with nothing to
|
|
45
|
+
* isolate returns unchanged, so the common dispatch shares one frozen object with every
|
|
46
|
+
* listener and pays no copies at all.
|
|
47
|
+
*
|
|
48
|
+
* Precondition: the value was produced by frozenSnapshot/deepFreezeInPlace. A shallow-walk
|
|
49
|
+
* finding of nothing to copy returns the input; a rebuilt branch is re-frozen in place, so
|
|
50
|
+
* the result satisfies the same deep-freeze invariant as the input.
|
|
51
|
+
*/
|
|
52
|
+
export declare function withFreshTypedArrays<T>(value: T): T;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The player's one clone/freeze family.
|
|
3
|
+
*
|
|
4
|
+
* Everything the player snapshots (session views, transitions, serialized
|
|
5
|
+
* state, delivered interaction data, definition configuration, presentation
|
|
6
|
+
* plans) goes through these helpers, so the treatment of the shapes that make
|
|
7
|
+
* deep-copying hazardous is defined once:
|
|
8
|
+
*
|
|
9
|
+
* - Plain objects and arrays are structurally deep-copied.
|
|
10
|
+
* - ArrayBuffers and typed arrays are copied and never frozen: a response's
|
|
11
|
+
* drawing `imageData` (`Uint8ClampedArray`) cannot be frozen — `Object.freeze`
|
|
12
|
+
* throws on a non-empty integer-indexed exotic object — and callers must stay
|
|
13
|
+
* able to read it after `state()`, serialize and restore.
|
|
14
|
+
* - TrustedHTML, `File`, `Blob` and every other non-plain object keep their
|
|
15
|
+
* identity as terminal leaves. `structuredClone` would throw `DataCloneError`
|
|
16
|
+
* on a TrustedHTML value, so presentation and extraction data — which carry
|
|
17
|
+
* TrustedHTML once a Trusted Types policy is configured — are never handed to
|
|
18
|
+
* it; a host-owned object a plugin supplied deliberately must survive
|
|
19
|
+
* delivery as the same object.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Structural deep copy of plain data. Typed arrays and buffers are copied;
|
|
23
|
+
* non-plain objects keep their identity; nothing is frozen.
|
|
24
|
+
*/
|
|
25
|
+
export function cloneValue(value) {
|
|
26
|
+
if (Array.isArray(value)) {
|
|
27
|
+
return value.map((entry) => cloneValue(entry));
|
|
28
|
+
}
|
|
29
|
+
if (!value || typeof value !== 'object')
|
|
30
|
+
return value;
|
|
31
|
+
if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {
|
|
32
|
+
return structuredClone(value);
|
|
33
|
+
}
|
|
34
|
+
// TrustedHTML, File, Blob and other class instances are terminal leaves (see
|
|
35
|
+
// the module doc): not structured-cloned, not recreated, identity preserved.
|
|
36
|
+
const prototype = Object.getPrototypeOf(value);
|
|
37
|
+
if (prototype !== Object.prototype && prototype !== null)
|
|
38
|
+
return value;
|
|
39
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [
|
|
40
|
+
key,
|
|
41
|
+
cloneValue(entry),
|
|
42
|
+
]));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* In-place deep freeze of a data graph. Plain objects and arrays are frozen;
|
|
46
|
+
* non-plain leaves (TrustedHTML, File, Blob, typed arrays, host objects) are
|
|
47
|
+
* returned untouched — freezing a browser-owned object can throw and freezing
|
|
48
|
+
* a typed array always would. An already-frozen node short-circuits its subtree.
|
|
49
|
+
*/
|
|
50
|
+
export function deepFreezeInPlace(value) {
|
|
51
|
+
if (!value || typeof value !== 'object' || Object.isFrozen(value))
|
|
52
|
+
return value;
|
|
53
|
+
const prototype = Object.getPrototypeOf(value);
|
|
54
|
+
if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null)
|
|
55
|
+
return value;
|
|
56
|
+
Object.freeze(value);
|
|
57
|
+
for (const child of Object.values(value)) {
|
|
58
|
+
deepFreezeInPlace(child);
|
|
59
|
+
}
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Clone and freeze plain data without mutating values owned by the caller or a
|
|
64
|
+
* PCI module: `cloneValue`'s copy, deeply frozen.
|
|
65
|
+
*/
|
|
66
|
+
export function frozenSnapshot(value) {
|
|
67
|
+
return deepFreezeInPlace(cloneValue(value));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A hand-out copy of an ALREADY deeply frozen snapshot for one recipient. The frozen plain
|
|
71
|
+
* structure is shared as-is — freezing makes it unobservable to mutation — but every
|
|
72
|
+
* typed-array leaf, which the platform cannot freeze, is re-copied, so recipients never
|
|
73
|
+
* share the snapshot's mutable unfrozen data (listeners pin that isolation, see
|
|
74
|
+
* tests/core/assessment-item-definition.test.ts "detaches drawing response data"). Non-plain
|
|
75
|
+
* leaves keep their identity, as everywhere in this family. A snapshot with nothing to
|
|
76
|
+
* isolate returns unchanged, so the common dispatch shares one frozen object with every
|
|
77
|
+
* listener and pays no copies at all.
|
|
78
|
+
*
|
|
79
|
+
* Precondition: the value was produced by frozenSnapshot/deepFreezeInPlace. A shallow-walk
|
|
80
|
+
* finding of nothing to copy returns the input; a rebuilt branch is re-frozen in place, so
|
|
81
|
+
* the result satisfies the same deep-freeze invariant as the input.
|
|
82
|
+
*/
|
|
83
|
+
export function withFreshTypedArrays(value) {
|
|
84
|
+
return isolateTypedArrays(value);
|
|
85
|
+
}
|
|
86
|
+
function isolateTypedArrays(value) {
|
|
87
|
+
if (Array.isArray(value)) {
|
|
88
|
+
let changed = false;
|
|
89
|
+
const copy = value.map((entry) => {
|
|
90
|
+
const next = isolateTypedArrays(entry);
|
|
91
|
+
changed || (changed = next !== entry);
|
|
92
|
+
return next;
|
|
93
|
+
});
|
|
94
|
+
return changed ? deepFreezeInPlace(copy) : value;
|
|
95
|
+
}
|
|
96
|
+
if (!value || typeof value !== 'object')
|
|
97
|
+
return value;
|
|
98
|
+
if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer)
|
|
99
|
+
return structuredClone(value);
|
|
100
|
+
const prototype = Object.getPrototypeOf(value);
|
|
101
|
+
// TrustedHTML, File, Blob and other class instances are terminal leaves (see the
|
|
102
|
+
// module doc): identity preserved, nothing to isolate.
|
|
103
|
+
if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null)
|
|
104
|
+
return value;
|
|
105
|
+
let changed = false;
|
|
106
|
+
const entries = Object.entries(value).map(([key, entry]) => {
|
|
107
|
+
const next = isolateTypedArrays(entry);
|
|
108
|
+
changed || (changed = next !== entry);
|
|
109
|
+
return [key, next];
|
|
110
|
+
});
|
|
111
|
+
return changed ? deepFreezeInPlace(Object.fromEntries(entries)) : value;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=cloneFreeze.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloneF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S,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC/C,iFAAiF;IACjF,uDAAuD;IACvD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS,IAAI,SAAS,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAChG,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACrF,MAAM,IAAI,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;QACvC,OAAO,KAAP,OAAO,GAAK,IAAI,KAAK,KAAK,EAAC;QAC3B,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACzE,CAAC","sourcesContent":["/**\n * The player's one clone/freeze family.\n *\n * Everything the player snapshots (session views, transitions, serialized\n * state, delivered interaction data, definition configuration, presentation\n * plans) goes through these helpers, so the treatment of the shapes that make\n * deep-copying hazardous is defined once:\n *\n * - Plain objects and arrays are structurally deep-copied.\n * - ArrayBuffers and typed arrays are copied and never frozen: a response's\n * drawing `imageData` (`Uint8ClampedArray`) cannot be frozen — `Object.freeze`\n * throws on a non-empty integer-indexed exotic object — and callers must stay\n * able to read it after `state()`, serialize and restore.\n * - TrustedHTML, `File`, `Blob` and every other non-plain object keep their\n * identity as terminal leaves. `structuredClone` would throw `DataCloneError`\n * on a TrustedHTML value, so presentation and extraction data — which carry\n * TrustedHTML once a Trusted Types policy is configured — are never handed to\n * it; a host-owned object a plugin supplied deliberately must survive\n * delivery as the same object.\n */\n\n/**\n * Structural deep copy of plain data. Typed arrays and buffers are copied;\n * non-plain objects keep their identity; nothing is frozen.\n */\nexport function cloneValue<T>(value: T): T {\n\tif (Array.isArray(value)) {\n\t\treturn value.map((entry) => cloneValue(entry)) as unknown as T;\n\t}\n\tif (!value || typeof value !== 'object') return value;\n\tif (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {\n\t\treturn structuredClone(value);\n\t}\n\t// TrustedHTML, File, Blob and other class instances are terminal leaves (see\n\t// the module doc): not structured-cloned, not recreated, identity preserved.\n\tconst prototype = Object.getPrototypeOf(value);\n\tif (prototype !== Object.prototype && prototype !== null) return value;\n\treturn Object.fromEntries(\n\t\tObject.entries(value as Record<string, unknown>).map(([key, entry]) => [\n\t\t\tkey,\n\t\t\tcloneValue(entry),\n\t\t]),\n\t) as T;\n}\n\n/**\n * In-place deep freeze of a data graph. Plain objects and arrays are frozen;\n * non-plain leaves (TrustedHTML, File, Blob, typed arrays, host objects) are\n * returned untouched — freezing a browser-owned object can throw and freezing\n * a typed array always would. An already-frozen node short-circuits its subtree.\n */\nexport function deepFreezeInPlace<T>(value: T): T {\n\tif (!value || typeof value !== 'object' || Object.isFrozen(value)) return value;\n\tconst prototype = Object.getPrototypeOf(value);\n\tif (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) return value;\n\tObject.freeze(value);\n\tfor (const child of Object.values(value as Record<string, unknown>)) {\n\t\tdeepFreezeInPlace(child);\n\t}\n\treturn value;\n}\n\n/**\n * Clone and freeze plain data without mutating values owned by the caller or a\n * PCI module: `cloneValue`'s copy, deeply frozen.\n */\nexport function frozenSnapshot<T>(value: T): T {\n\treturn deepFreezeInPlace(cloneValue(value));\n}\n\n/**\n * A hand-out copy of an ALREADY deeply frozen snapshot for one recipient. The frozen plain\n * structure is shared as-is — freezing makes it unobservable to mutation — but every\n * typed-array leaf, which the platform cannot freeze, is re-copied, so recipients never\n * share the snapshot's mutable unfrozen data (listeners pin that isolation, see\n * tests/core/assessment-item-definition.test.ts \"detaches drawing response data\"). Non-plain\n * leaves keep their identity, as everywhere in this family. A snapshot with nothing to\n * isolate returns unchanged, so the common dispatch shares one frozen object with every\n * listener and pays no copies at all.\n *\n * Precondition: the value was produced by frozenSnapshot/deepFreezeInPlace. A shallow-walk\n * finding of nothing to copy returns the input; a rebuilt branch is re-frozen in place, so\n * the result satisfies the same deep-freeze invariant as the input.\n */\nexport function withFreshTypedArrays<T>(value: T): T {\n\treturn isolateTypedArrays(value) as T;\n}\n\nfunction isolateTypedArrays(value: unknown): unknown {\n\tif (Array.isArray(value)) {\n\t\tlet changed = false;\n\t\tconst copy = value.map((entry) => {\n\t\t\tconst next = isolateTypedArrays(entry);\n\t\t\tchanged ||= next !== entry;\n\t\t\treturn next;\n\t\t});\n\t\treturn changed ? deepFreezeInPlace(copy) : value;\n\t}\n\tif (!value || typeof value !== 'object') return value;\n\tif (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) return structuredClone(value);\n\tconst prototype = Object.getPrototypeOf(value);\n\t// TrustedHTML, File, Blob and other class instances are terminal leaves (see the\n\t// module doc): identity preserved, nothing to isolate.\n\tif (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) return value;\n\tlet changed = false;\n\tconst entries = Object.entries(value as Record<string, unknown>).map(([key, entry]) => {\n\t\tconst next = isolateTypedArrays(entry);\n\t\tchanged ||= next !== entry;\n\t\treturn [key, next];\n\t});\n\treturn changed ? deepFreezeInPlace(Object.fromEntries(entries)) : value;\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads one attribute out of a serialized HTML attribute string — the attribute text of a matched
|
|
3
|
+
* tag (e.g. a regex capture of `<gap identifier="g1">`), not a DOM element. This is the one reader
|
|
4
|
+
* for markup the player handles as text: the gap-match extractor's prompt rewriting, the
|
|
5
|
+
* presentation pass's stimulus docking, and the feedback announcement's feedback tags.
|
|
6
|
+
*
|
|
7
|
+
* Quote pairs must match, an empty value is a value (`identifier=""` is present and empty, not
|
|
8
|
+
* absent), and a camelCase name also tries its kebab spelling (`outcomeIdentifier` or
|
|
9
|
+
* `outcome-identifier`), since QTI 2.x and QTI 3.0 spell attributes differently. Only whitespace
|
|
10
|
+
* may precede the name, so `data-identifier` does not read as `identifier`. Returns null when the
|
|
11
|
+
* attribute is absent; otherwise its value, untrimmed.
|
|
12
|
+
*/
|
|
13
|
+
export declare function readHtmlAttribute(attrs: string, name: string): string | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads one attribute out of a serialized HTML attribute string — the attribute text of a matched
|
|
3
|
+
* tag (e.g. a regex capture of `<gap identifier="g1">`), not a DOM element. This is the one reader
|
|
4
|
+
* for markup the player handles as text: the gap-match extractor's prompt rewriting, the
|
|
5
|
+
* presentation pass's stimulus docking, and the feedback announcement's feedback tags.
|
|
6
|
+
*
|
|
7
|
+
* Quote pairs must match, an empty value is a value (`identifier=""` is present and empty, not
|
|
8
|
+
* absent), and a camelCase name also tries its kebab spelling (`outcomeIdentifier` or
|
|
9
|
+
* `outcome-identifier`), since QTI 2.x and QTI 3.0 spell attributes differently. Only whitespace
|
|
10
|
+
* may precede the name, so `data-identifier` does not read as `identifier`. Returns null when the
|
|
11
|
+
* attribute is absent; otherwise its value, untrimmed.
|
|
12
|
+
*/
|
|
13
|
+
export function readHtmlAttribute(attrs, name) {
|
|
14
|
+
const kebab = name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
15
|
+
for (const spelling of kebab === name ? [name] : [name, kebab]) {
|
|
16
|
+
const match = new RegExp(`(?:^|\\s)${spelling}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`, 'i').exec(attrs);
|
|
17
|
+
if (match)
|
|
18
|
+
return match[1] ?? match[2] ?? '';
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=htmlAttributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"htmlAttributes.js","sourceRoot":"","sources":["../../src/utils/htmlAttributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa,EAAE,IAAY;IAC5D,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAC7E,KAAK,MAAM,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;QAChE,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,YAAY,QAAQ,kCAAkC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClG,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9C,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/**\n * Reads one attribute out of a serialized HTML attribute string — the attribute text of a matched\n * tag (e.g. a regex capture of `<gap identifier=\"g1\">`), not a DOM element. This is the one reader\n * for markup the player handles as text: the gap-match extractor's prompt rewriting, the\n * presentation pass's stimulus docking, and the feedback announcement's feedback tags.\n *\n * Quote pairs must match, an empty value is a value (`identifier=\"\"` is present and empty, not\n * absent), and a camelCase name also tries its kebab spelling (`outcomeIdentifier` or\n * `outcome-identifier`), since QTI 2.x and QTI 3.0 spell attributes differently. Only whitespace\n * may precede the name, so `data-identifier` does not read as `identifier`. Returns null when the\n * attribute is absent; otherwise its value, untrimmed.\n */\nexport function readHtmlAttribute(attrs: string, name: string): string | null {\n\tconst kebab = name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n\tfor (const spelling of kebab === name ? [name] : [name, kebab]) {\n\t\tconst match = new RegExp(`(?:^|\\\\s)${spelling}\\\\s*=\\\\s*(?:\"([^\"]*)\"|'([^']*)')`, 'i').exec(attrs);\n\t\tif (match) return match[1] ?? match[2] ?? '';\n\t}\n\treturn null;\n}\n"]}
|
|
@@ -48,32 +48,3 @@ export interface QTIChangeEventDetail<TValue = InteractionResponseValue | null>
|
|
|
48
48
|
export declare class QTIChangeEvent<TValue = InteractionResponseValue | null> extends CustomEvent<QTIChangeEventDetail<TValue>> {
|
|
49
49
|
constructor(detail: QTIChangeEventDetail<TValue>);
|
|
50
50
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Event emitted when a component is ready (initialized and rendered)
|
|
53
|
-
*/
|
|
54
|
-
export declare class QTIReadyEvent extends CustomEvent<void> {
|
|
55
|
-
constructor();
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Event emitted when an error occurs in a component
|
|
59
|
-
*/
|
|
60
|
-
export interface QTIErrorEventDetail {
|
|
61
|
-
/** The error that occurred */
|
|
62
|
-
error: Error;
|
|
63
|
-
/** Context about where the error occurred */
|
|
64
|
-
context: string;
|
|
65
|
-
}
|
|
66
|
-
export declare class QTIErrorEvent extends CustomEvent<QTIErrorEventDetail> {
|
|
67
|
-
constructor(detail: QTIErrorEventDetail);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Special event for AssociateInteraction selection state
|
|
71
|
-
* (used for tracking which item is selected for pairing)
|
|
72
|
-
*/
|
|
73
|
-
export interface QTISelectionChangeEventDetail {
|
|
74
|
-
/** The identifier of the selected item, or null if deselected */
|
|
75
|
-
selected: string | null;
|
|
76
|
-
}
|
|
77
|
-
export declare class QTISelectionChangeEvent extends CustomEvent<QTISelectionChangeEventDetail> {
|
|
78
|
-
constructor(detail: QTISelectionChangeEventDetail);
|
|
79
|
-
}
|
|
@@ -27,36 +27,4 @@ export class QTIChangeEvent extends CustomEvent {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Event emitted when a component is ready (initialized and rendered)
|
|
32
|
-
*/
|
|
33
|
-
export class QTIReadyEvent extends CustomEvent {
|
|
34
|
-
constructor() {
|
|
35
|
-
super('qti-ready', {
|
|
36
|
-
bubbles: true,
|
|
37
|
-
composed: true,
|
|
38
|
-
cancelable: false,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export class QTIErrorEvent extends CustomEvent {
|
|
43
|
-
constructor(detail) {
|
|
44
|
-
super('qti-error', {
|
|
45
|
-
detail,
|
|
46
|
-
bubbles: true,
|
|
47
|
-
composed: true,
|
|
48
|
-
cancelable: false,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
export class QTISelectionChangeEvent extends CustomEvent {
|
|
53
|
-
constructor(detail) {
|
|
54
|
-
super('qti-selection-change', {
|
|
55
|
-
detail,
|
|
56
|
-
bubbles: true,
|
|
57
|
-
composed: true,
|
|
58
|
-
cancelable: false,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
30
|
//# sourceMappingURL=QTIInteractionElement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QTIInteractionElement.js","sourceRoot":"","sources":["../../src/web-components/QTIInteractionElement.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4CH;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,cAAyD,SAAQ,WAAyC;IACtH,YAAY,MAAoC;QAC/C,KAAK,CAAC,YAAY,EAAE;YACnB,MAAM;YACN,OAAO,EAAE,IAAI,EAAE,6BAA6B;YAC5C,QAAQ,EAAE,IAAI,EAAE,8BAA8B;YAC9C,UAAU,EAAE,KAAK,EAAE,sBAAsB;SACzC,CAAC,CAAC;IACJ,CAAC;CACD
|
|
1
|
+
{"version":3,"file":"QTIInteractionElement.js","sourceRoot":"","sources":["../../src/web-components/QTIInteractionElement.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4CH;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,cAAyD,SAAQ,WAAyC;IACtH,YAAY,MAAoC;QAC/C,KAAK,CAAC,YAAY,EAAE;YACnB,MAAM;YACN,OAAO,EAAE,IAAI,EAAE,6BAA6B;YAC5C,QAAQ,EAAE,IAAI,EAAE,8BAA8B;YAC9C,UAAU,EAAE,KAAK,EAAE,sBAAsB;SACzC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["/**\n * Standard interface and event types for QTI interaction web components\n *\n * All QTI interaction web components must implement the QTIInteractionElement\n * interface and emit QTIChangeEvent when the user response changes.\n */\n\nimport type { BaseInteractionData, InteractionValueMap } from '../interactions/shared/types.js';\n\nexport type InteractionResponseValue<TData extends BaseInteractionData = BaseInteractionData> =\n\tTData extends { type: infer TType }\n\t\t? TType extends keyof InteractionValueMap\n\t\t\t? InteractionValueMap[TType]\n\t\t\t: unknown\n\t\t: unknown;\n\n/**\n * Standard interface that all QTI interaction web components must implement\n */\nexport interface QTIInteractionElement<\n\tTData extends BaseInteractionData = BaseInteractionData,\n> extends HTMLElement {\n\t/** The processed interaction data from the QTI XML */\n\tinteraction: TData;\n\n\t/** The current response value (type depends on interaction type) */\n\tresponse: InteractionResponseValue<TData> | null;\n\n\t/** Whether the interaction is in read-only/disabled mode */\n\tdisabled: boolean;\n\n\t/** Optional function to apply math typesetting (e.g., KaTeX, MathJax) */\n\ttypeset?: (element: HTMLElement) => void;\n}\n\n/**\n * Detail payload for the qti-change event\n */\nexport interface QTIChangeEventDetail<TValue = InteractionResponseValue | null> {\n\t/** The response identifier for this interaction */\n\tresponseId: string;\n\n\t/** The new response value */\n\tvalue: TValue;\n\n\t/** Timestamp when the change occurred */\n\ttimestamp: number;\n}\n\n/**\n * Custom event emitted when an interaction's response changes\n *\n * This event bubbles and can cross shadow DOM boundaries, making it\n * easy to listen for changes at the container level.\n *\n * @example\n * ```typescript\n * element.addEventListener('qti-change', (event: QTIChangeEvent) => {\n * console.log('Response changed:', event.detail.responseId, event.detail.value);\n * });\n * ```\n */\nexport class QTIChangeEvent<TValue = InteractionResponseValue | null> extends CustomEvent<QTIChangeEventDetail<TValue>> {\n\tconstructor(detail: QTIChangeEventDetail<TValue>) {\n\t\tsuper('qti-change', {\n\t\t\tdetail,\n\t\t\tbubbles: true, // Bubble up through DOM tree\n\t\t\tcomposed: true, // Cross shadow DOM boundaries\n\t\t\tcancelable: false, // Cannot be prevented\n\t\t});\n\t}\n}\n"]}
|
|
@@ -3,5 +3,4 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Framework-agnostic web components that can be used in any JavaScript environment
|
|
5
5
|
*/
|
|
6
|
-
export {
|
|
7
|
-
export { QTIChangeEvent, type InteractionResponseValue, type QTIChangeEventDetail, QTIErrorEvent, type QTIErrorEventDetail, type QTIInteractionElement, QTIReadyEvent, QTISelectionChangeEvent, type QTISelectionChangeEventDetail, } from './QTIInteractionElement.js';
|
|
6
|
+
export { QTIChangeEvent, type InteractionResponseValue, type QTIChangeEventDetail, type QTIInteractionElement, } from './QTIInteractionElement.js';
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Framework-agnostic web components that can be used in any JavaScript environment
|
|
5
5
|
*/
|
|
6
|
-
// Export
|
|
7
|
-
export {
|
|
8
|
-
export { QTIChangeEvent, QTIErrorEvent, QTIReadyEvent, QTISelectionChangeEvent, } from './QTIInteractionElement.js';
|
|
6
|
+
// Export event classes and interfaces
|
|
7
|
+
export { QTIChangeEvent, } from './QTIInteractionElement.js';
|
|
9
8
|
// Note: Web component implementations are provided by separate packages
|
|
10
9
|
// (e.g., @pie-qti/default-components) that use these base classes
|
|
11
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/web-components/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/web-components/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,sCAAsC;AACtC,OAAO,EACN,cAAc,GAId,MAAM,4BAA4B,CAAC;AAEpC,wEAAwE;AACxE,kEAAkE","sourcesContent":["/**\n * Web Components for QTI Interactions\n *\n * Framework-agnostic web components that can be used in any JavaScript environment\n */\n\n// Export event classes and interfaces\nexport {\n\tQTIChangeEvent,\n\ttype InteractionResponseValue,\n\ttype QTIChangeEventDetail,\n\ttype QTIInteractionElement,\n} from './QTIInteractionElement.js';\n\n// Note: Web component implementations are provided by separate packages\n// (e.g., @pie-qti/default-components) that use these base classes\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-qti/item-player",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.6",
|
|
4
4
|
"description": "Modern QTI player supporting QTI 2.2 and 3.0 - Client-side with optional backend hooks",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "vite build && tsc",
|
|
10
10
|
"dev": "tsc --watch",
|
|
11
|
-
"test": "bun test && tsc -p ./tsconfig.server-types.test.json",
|
|
12
|
-
"
|
|
11
|
+
"test": "bun test && tsc -p ./tsconfig.server-types.test.json && bun run test:component",
|
|
12
|
+
"test:component": "vitest run",
|
|
13
|
+
"typecheck": "tsc --noEmit && tsc -p ./tsconfig.test.json --noEmit",
|
|
13
14
|
"check": "svelte-check --tsconfig ./tsconfig.svelte.json",
|
|
14
15
|
"lint": "biome check .",
|
|
15
16
|
"lint:fix": "biome check --write .",
|
|
@@ -27,22 +28,24 @@
|
|
|
27
28
|
],
|
|
28
29
|
"license": "MIT",
|
|
29
30
|
"dependencies": {
|
|
30
|
-
"@pie-qti/i18n": "1.0.0-beta.
|
|
31
|
-
"@pie-qti/ims-cp-core": "1.0.0-beta.
|
|
32
|
-
"@pie-qti/qti-common": "1.0.0-beta.
|
|
33
|
-
"@pie-qti/qti-processing": "1.0.0-beta.
|
|
34
|
-
"
|
|
35
|
-
"node-html-parser": "^9.0.5"
|
|
31
|
+
"@pie-qti/i18n": "1.0.0-beta.6",
|
|
32
|
+
"@pie-qti/ims-cp-core": "1.0.0-beta.6",
|
|
33
|
+
"@pie-qti/qti-common": "1.0.0-beta.6",
|
|
34
|
+
"@pie-qti/qti-processing": "1.0.0-beta.6",
|
|
35
|
+
"node-html-parser": "^9.0.7"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@biomejs/biome": "^2.6.
|
|
38
|
+
"@biomejs/biome": "^2.6.8",
|
|
39
39
|
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|
|
40
|
-
"@types/node": "^26.6.
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
40
|
+
"@types/node": "^26.6.6",
|
|
41
|
+
"jsdom": "^31.0.1",
|
|
42
|
+
"linkedom": "^0.18.13",
|
|
43
|
+
"svelte": "^5.57.3",
|
|
44
|
+
"svelte-check": "^4.7.8",
|
|
45
|
+
"typescript": "^6.0.3",
|
|
46
|
+
"vite": "^8.3.8",
|
|
47
|
+
"vite-plugin-dts": "^5.1.2",
|
|
48
|
+
"vitest": "^5.1.0"
|
|
46
49
|
},
|
|
47
50
|
"exports": {
|
|
48
51
|
".": {
|
|
@@ -98,7 +101,5 @@
|
|
|
98
101
|
},
|
|
99
102
|
"files": [
|
|
100
103
|
"dist"
|
|
101
|
-
]
|
|
102
|
-
"unpkg": "./dist/element.js",
|
|
103
|
-
"jsdelivr": "./dist/element.js"
|
|
104
|
+
]
|
|
104
105
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stimulusRender.js","sourceRoot":"","sources":["../../../src/components/utils/stimulusRender.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAC5C,eAAwD,EACxD,QAA2B;IAE3B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AAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/D,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACvB,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,SAAS,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;AAC/F,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa;IACzC,OAAO,KAAK;SACV,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACzB,CAAC","sourcesContent":["import type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';\n\nexport type StimulusSanitizer = (html: string) => string;\n\n/**\n * Build the effective stimulus content map for an item render.\n *\n * Resolved delivery-context content is the package/assessment source of truth.\n */\nexport function buildEffectiveStimulusContent(\n\tdeliveryContext: ResolvedItemDeliveryContext | undefined,\n\tsanitize: StimulusSanitizer\n): Record<string, string> {\n\treturn Object.fromEntries(\n\t\tObject.entries(deliveryContext?.stimuli ?? {}).map(([identifier, stimulus]) => [\n\t\t\tidentifier,\n\t\t\tsanitize(stimulus.bodyHtml),\n\t\t])\n\t);\n}\n\n/**\n * Inject shared stimulus bodies at QTI refs or host-authored docking points.\n *\n * Any resolved stimulus that has no matching docking point is prepended in\n * delivery-context order so undocked package content is still visible.\n */\nexport function injectStimulusContent(itemBodyHtml: string, stimulusContent: Record<string, string>): string {\n\tif (Object.keys(stimulusContent).length === 0) return itemBodyHtml;\n\n\tconst docked = new Set<string>();\n\tlet html = itemBodyHtml.replace(\n\t\t/<([a-z][\\w:-]*)([^>]*\\bdata-stimulus-idref=([\"'])([^\"']+)\\3[^>]*)>\\s*<\\/\\1>/gi,\n\t\t(match, tagName, attrs, _quote, identifier) => {\n\t\t\tconst content = stimulusContent[identifier];\n\t\t\tif (!content) return match;\n\t\t\tdocked.add(identifier);\n\t\t\treturn `<${tagName}${mergeClassAttribute(attrs, 'qti-stimulus-dock')}>${content}</${tagName}>`;\n\t\t}\n\t);\n\n\thtml = html.replace(\n\t\t/<qti-assessment-stimulus-ref\\b([^>]*)\\/?>\\s*(?:<\\/qti-assessment-stimulus-ref>)?/gi,\n\t\t(match, attrs) => {\n\t\t\tconst identifier = extractAttribute(attrs, 'identifier');\n\t\t\tif (!identifier) return match;\n\t\t\tif (docked.has(identifier)) return '';\n\t\t\tconst content = stimulusContent[identifier];\n\t\t\tif (!content) return match;\n\t\t\tdocked.add(identifier);\n\t\t\treturn `<div data-stimulus-idref=\"${escapeHtmlAttribute(identifier)}\" class=\"qti-stimulus-dock\">${content}</div>`;\n\t\t}\n\t);\n\n\tconst undocked = Object.entries(stimulusContent)\n\t\t.filter(([identifier]) => !docked.has(identifier))\n\t\t.map(\n\t\t\t([identifier, content]) =>\n\t\t\t\t`<div data-stimulus-idref=\"${escapeHtmlAttribute(identifier)}\" class=\"qti-stimulus-block\">${content}</div>`\n\t\t)\n\t\t.join('');\n\n\treturn undocked ? undocked + html : html;\n}\n\nfunction extractAttribute(attrs: string, name: string): string | null {\n\tconst match = attrs.match(new RegExp(`\\\\b${name}\\\\s*=\\\\s*[\"']([^\"']+)[\"']`, 'i'));\n\treturn match?.[1] ?? null;\n}\n\nfunction mergeClassAttribute(attrs: string, className: string): string {\n\tconst classMatch = attrs.match(/\\bclass\\s*=\\s*([\"'])([^\"']*)\\1/i);\n\tif (!classMatch) return `${attrs} class=\"${className}\"`;\n\tconst quote = classMatch[1]!;\n\tconst existing = classMatch[2] ?? '';\n\tconst classes = new Set(existing.split(/\\s+/).filter(Boolean));\n\tclasses.add(className);\n\treturn attrs.replace(classMatch[0], `class=${quote}${Array.from(classes).join(' ')}${quote}`);\n}\n\nfunction escapeHtmlAttribute(value: string): string {\n\treturn value\n\t\t.replace(/&/g, '&')\n\t\t.replace(/\"/g, '"')\n\t\t.replace(/</g, '<')\n\t\t.replace(/>/g, '>');\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stylesheetRender.js","sourceRoot":"","sources":["../../../src/components/utils/stylesheetRender.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,MAAM,UAAU,wBAAwB,CACvC,eAAwD,EACxD,aAAa,GAAG,4BAA4B;IAE5C,IAAI,CAAC,eAAe;QAAE,OAAO,EAAE,CAAC;IAChC,OAAO,eAAe,CAAC,WAAW;SAChC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,qBAAqB,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;SACrE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC;AAED,SAAS,qBAAqB,CAAC,UAAoC,EAAE,aAAqB;IACzF,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;IACvC,IAAI,CAAC,GAAG,IAAI,sBAAsB,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IACnD,MAAM,eAAe,GAAG,0BAA0B,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAC9E,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;IACnD,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAE3F,wFAAwF;AACxF,MAAM,oBAAoB,GAAG,+BAA+B,CAAC;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AAC;AACpF,CAAC","sourcesContent":["import type { ResolvedItemDeliveryContext, ResolvedQtiStylesheetRef } from '@pie-qti/ims-cp-core';\nimport { isBlockedStylesheetCss } from '@pie-qti/ims-cp-core';\n\nexport function buildScopedStylesheetCss(\n\tdeliveryContext: ResolvedItemDeliveryContext | undefined,\n\tscopeSelector = '[data-qti-item-body-scope]'\n): string {\n\tif (!deliveryContext) return '';\n\treturn deliveryContext.stylesheets\n\t\t.map((stylesheet) => stylesheetToScopedCss(stylesheet, scopeSelector))\n\t\t.filter(Boolean)\n\t\t.join('\\n');\n}\n\nfunction stylesheetToScopedCss(stylesheet: ResolvedQtiStylesheetRef, scopeSelector: string): string {\n\tconst css = stylesheet.cssText?.trim();\n\tif (!css || isBlockedStylesheetCss(css)) return '';\n\tconst stylesheetScope = getStylesheetScopeSelector(stylesheet, scopeSelector);\n\tconst scoped = scopeCssRules(css, stylesheetScope);\n\tif (!scoped) return '';\n\treturn scoped;\n}\n\n/**\n * At-rules whose block contains nested *rules*, so scoping recurses into the\n * block while the prelude is preserved verbatim.\n *\n * Anything not listed here is passed through untouched. That is the safe\n * default both ways: at-rules whose block holds declarations rather than rules\n * (`@font-face`, `@page`, `@property`, `@counter-style`) or non-selector keys\n * (`@keyframes` percentages) must not be scoped, and an at-rule this list has\n * never heard of is more safely left alone than guessed at.\n */\nconst NESTED_RULE_AT_RULES = new Set(['media', 'supports', 'container', 'layer', 'scope']);\n\n/** Matches a leading `:root`, `html` or `body` not followed by more name characters. */\nconst DOCUMENT_ROOT_PREFIX = /^(?::root|html|body)(?![\\w-])/;\n\n/** Matches an at-rule name, with any vendor prefix, at the start of a prelude. */\nconst AT_RULE_NAME = /^@(?:-[a-z]+-)?([\\w-]+)/i;\n\ntype StyleNode =\n\t/** A `;`-terminated at-rule with no block, such as `@layer a;`. */\n\t| { kind: 'statement'; text: string; end: number }\n\t/** A prelude plus a `{ ... }` block: a style rule or a block at-rule. */\n\t| { kind: 'rule'; prelude: string; block: string; end: number }\n\t/** Trailing text with no rule in it, kept so nothing is silently dropped. */\n\t| { kind: 'trailing'; text: string; end: number };\n\n/**\n * Confine every selector in `css` to `scopeSelector`.\n *\n * This walks the stylesheet brace-by-brace. It used to be a single regex over\n * `([^{}@]+)\\{([^{}]*)\\}`, which handled flat selector rules and silently\n * destroyed at-rules. Because `@` was excluded from the selector pattern rather\n * than *understood*, an `@media` block never matched as a unit, so the inner\n * rules matched on their own and were emitted **without the condition** — the\n * media query was dropped and its rules applied unconditionally, so a\n * print-only or narrow-viewport rule took effect everywhere. `@keyframes`\n * degraded the same way, with its percentage selectors scoped into\n * `[scope] 0%` and the animation name discarded, and `@font-face` became\n * `[scope] font-face`.\n *\n * A CSS parser would be the textbook answer and is deliberately not added:\n * scoping needs rule boundaries only, not property grammar, and this runs in\n * the delivery path.\n *\n * Note that `isBlockedStylesheetCss` rejects any stylesheet containing `url(`\n * or `@import` before this is reached, so `@font-face` with a real `src` never\n * arrives here in practice. `@media`, `@supports` and `@keyframes` do.\n */\nexport function scopeCssRules(css: string, scopeSelector = '[data-qti-item-body-scope]'): string {\n\tif (!css) return '';\n\tconst scope = scopeSelector?.trim();\n\tif (!scope) return css;\n\treturn scopeRuleList(stripComments(css), scope).trim();\n}\n\nfunction scopeRuleList(css: string, scope: string): string {\n\tlet out = '';\n\tlet index = 0;\n\twhile (index < css.length) {\n\t\tconst node = readNode(css, index);\n\t\tif (node.end <= index) break;\n\t\tout += renderNode(node, scope);\n\t\tindex = node.end;\n\t}\n\treturn out;\n}\n\nfunction renderNode(node: StyleNode, scope: string): string {\n\tif (node.kind === 'statement') {\n\t\tconst text = node.text.trim();\n\t\treturn text === ';' ? '' : `${text}\\n`;\n\t}\n\tif (node.kind === 'trailing') {\n\t\treturn node.text.trim() ? `${node.text.trim()}\\n` : '';\n\t}\n\tconst prelude = node.prelude.trim();\n\tif (!prelude) return '';\n\tif (prelude.startsWith('@')) {\n\t\tconst name = AT_RULE_NAME.exec(prelude)?.[1]?.toLowerCase();\n\t\tif (name && NESTED_RULE_AT_RULES.has(name)) {\n\t\t\tconst inner = scopeRuleList(node.block, scope);\n\t\t\tif (!inner.trim()) return '';\n\t\t\treturn `${prelude} {\\n${inner}}\\n`;\n\t\t}\n\t\treturn `${prelude} {${node.block}}\\n`;\n\t}\n\t// Rules with no declarations are dropped, as they were before.\n\tconst declarations = node.block.trim();\n\tif (!declarations) return '';\n\tconst selectors = splitTopLevel(prelude, ',')\n\t\t.map((selector) => scopeSelectorText(selector.trim(), scope))\n\t\t.filter(Boolean);\n\tif (selectors.length === 0) return '';\n\treturn `${selectors.join(', ')} { ${declarations} }\\n`;\n}\n\nfunction getStylesheetScopeSelector(stylesheet: ResolvedQtiStylesheetRef, scopeSelector: string): string {\n\tif (stylesheet.source !== 'stimulus' || !stylesheet.stimulusIdentifier) return scopeSelector;\n\treturn `${scopeSelector} [data-stimulus-idref=\"${escapeCssString(stylesheet.stimulusIdentifier)}\"]`;\n}\n\nfunction scopeSelectorText(selector: string, scopeSelector: string): string {\n\tif (!selector) return '';\n\tif (selector === scopeSelector || selector.startsWith(`${scopeSelector} `)) return selector;\n\t// `:root`/`html`/`body` are replaced rather than prefixed: `[scope] :root`\n\t// cannot match, because `:root` is the document element and is not a\n\t// descendant of the item body. Whatever followed is preserved, so\n\t// `html.dark .a` becomes `[scope].dark .a`.\n\tconst rootPrefix = DOCUMENT_ROOT_PREFIX.exec(selector);\n\tif (rootPrefix) return `${scopeSelector}${selector.slice(rootPrefix[0].length)}`;\n\t// Everything else becomes a descendant, including a leading pseudo. This\n\t// used to attach — `[scope]:is(.a, .b)` — which is a different selector: an\n\t// authored `:is(.a, .b) .c` means \"some element matching .a or .b\", so\n\t// attaching demands that the item body itself carry the authored class, and\n\t// it does not. The same holds for `:hover` and `::selection`.\n\treturn `${scopeSelector} ${selector}`;\n}\n\n/**\n * Read one node starting at `start`, tracking strings and parentheses so a `{`\n * inside `content: \"{\"` or a `,` inside `:is(a, b)` is not mistaken for\n * structure.\n */\nfunction readNode(css: string, start: number): StyleNode {\n\tlet index = start;\n\tlet quote: string | null = null;\n\tlet parenDepth = 0;\n\twhile (index < css.length) {\n\t\tconst char = css[index];\n\t\tif (quote) {\n\t\t\tif (char === '\\\\') index += 1;\n\t\t\telse if (char === quote) quote = null;\n\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\tquote = char;\n\t\t} else if (char === '(') {\n\t\t\tparenDepth += 1;\n\t\t} else if (char === ')') {\n\t\t\tif (parenDepth > 0) parenDepth -= 1;\n\t\t} else if (parenDepth === 0 && char === ';') {\n\t\t\treturn { kind: 'statement', text: css.slice(start, index + 1), end: index + 1 };\n\t\t} else if (parenDepth === 0 && char === '{') {\n\t\t\tconst blockEnd = findBlockEnd(css, index);\n\t\t\treturn {\n\t\t\t\tkind: 'rule',\n\t\t\t\tprelude: css.slice(start, index),\n\t\t\t\tblock: css.slice(index + 1, blockEnd.contentEnd),\n\t\t\t\tend: blockEnd.end,\n\t\t\t};\n\t\t}\n\t\tindex += 1;\n\t}\n\treturn { kind: 'trailing', text: css.slice(start), end: css.length };\n}\n\n/**\n * Find the `}` matching the `{` at `openIndex`. Unbalanced input — a truncated\n * stylesheet — is treated as running to the end rather than throwing.\n */\nfunction findBlockEnd(css: string, openIndex: number): { contentEnd: number; end: number } {\n\tlet depth = 0;\n\tlet quote: string | null = null;\n\tfor (let index = openIndex; index < css.length; index += 1) {\n\t\tconst char = css[index];\n\t\tif (quote) {\n\t\t\tif (char === '\\\\') index += 1;\n\t\t\telse if (char === quote) quote = null;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '\"' || char === \"'\") {\n\t\t\tquote = char;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '{') depth += 1;\n\t\telse if (char === '}') {\n\t\t\tdepth -= 1;\n\t\t\tif (depth === 0) return { contentEnd: index, end: index + 1 };\n\t\t}\n\t}\n\treturn { contentEnd: css.length, end: css.length };\n}\n\n/** Split on `separator` at paren depth zero and outside strings. */\nfunction splitTopLevel(value: string, separator: string): string[] {\n\tconst parts: string[] = [];\n\tlet current = '';\n\tlet quote: string | null = null;\n\tlet parenDepth = 0;\n\tfor (let index = 0; index < value.length; index += 1) {\n\t\tconst char = value[index] as string;\n\t\tif (quote) {\n\t\t\tcurrent += char;\n\t\t\tif (char === '\\\\' && index + 1 < value.length) {\n\t\t\t\tcurrent += value[index + 1];\n\t\t\t\tindex += 1;\n\t\t\t} else if (char === quote) {\n\t\t\t\tquote = null;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '\"' || char === \"'\") {\n\t\t\tquote = char;\n\t\t\tcurrent += char;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '(') parenDepth += 1;\n\t\telse if (char === ')' && parenDepth > 0) parenDepth -= 1;\n\t\tif (char === separator && parenDepth === 0) {\n\t\t\tparts.push(current);\n\t\t\tcurrent = '';\n\t\t\tcontinue;\n\t\t}\n\t\tcurrent += char;\n\t}\n\tparts.push(current);\n\treturn parts;\n}\n\n/**\n * Remove comments before walking, so a comment between two rules is not\n * absorbed into the next rule's selector list. String-aware, so a literal\n * `content: \"/*\"` survives — the previous regex strip was not.\n */\nfunction stripComments(css: string): string {\n\tlet out = '';\n\tlet quote: string | null = null;\n\tlet index = 0;\n\twhile (index < css.length) {\n\t\tconst char = css[index] as string;\n\t\tif (quote) {\n\t\t\tout += char;\n\t\t\tif (char === '\\\\' && index + 1 < css.length) {\n\t\t\t\tout += css[index + 1];\n\t\t\t\tindex += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (char === quote) quote = null;\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '\"' || char === \"'\") {\n\t\t\tquote = char;\n\t\t\tout += char;\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '/' && css[index + 1] === '*') {\n\t\t\tconst close = css.indexOf('*/', index + 2);\n\t\t\tindex = close === -1 ? css.length : close + 2;\n\t\t\t// Keep a space so `a/**/b` does not become the single token `ab`.\n\t\t\tout += ' ';\n\t\t\tcontinue;\n\t\t}\n\t\tout += char;\n\t\tindex += 1;\n\t}\n\treturn out;\n}\n\nfunction escapeCssString(value: string): string {\n\treturn value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"').replace(/\\n|\\r|\\f/g, ' ');\n}\n"]}
|
package/dist/core/constants.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* QTI constants and configuration
|
|
3
|
-
*/
|
|
4
|
-
export declare const PREFIX = "pie-qti";
|
|
5
|
-
export declare const ID = "data-pie-qti-identifier";
|
|
6
|
-
export declare const RESPONSE_ID = "data-pie-qti-response-identifier";
|
|
7
|
-
export declare const TAG = "data-pie-qti-tag";
|
|
8
|
-
export declare const NAVMODE = "data-pie-qti-navigation-mode";
|
|
9
|
-
export declare const SHOWHIDE = "data-pie-qti-show-hide";
|
|
10
|
-
export declare const ANSWERED = "pie-qti-answered";
|
|
11
|
-
export declare const ASSOCIABLE = "pie-qti-associable";
|
|
12
|
-
export declare const ASSOCIATION = "pie-qti-association";
|
|
13
|
-
export declare const CHOICES = "pie-qti-choices";
|
|
14
|
-
export declare const CLICKED = "pie-qti-clicked";
|
|
15
|
-
export declare const CURRENT = "pie-qti-current";
|
|
16
|
-
export declare const DRAGGING = "pie-qti-dragging";
|
|
17
|
-
export declare const DRAGOVER = "pie-qti-dragover";
|
|
18
|
-
export declare const GAP = "pie-qti-gap";
|
|
19
|
-
export declare const GHOST = "pie-qti-ghost";
|
|
20
|
-
export declare const HOTSPOT = "pie-qti-hotspot";
|
|
21
|
-
export declare const INTERACTION = "pie-qti-interaction";
|
|
22
|
-
export declare const MATCH = "pie-qti-match";
|
|
23
|
-
export declare const MATCHED = "pie-qti-matched";
|
|
24
|
-
export declare const MODAL = "pie-qti-modal";
|
|
25
|
-
export declare const NAVIGATION = "pie-qti-navigation";
|
|
26
|
-
export declare const PIVOTABLE = "pie-qti-pivotable";
|
|
27
|
-
export declare const SELECTED = "pie-qti-selected";
|
|
28
|
-
export declare const ASSOCIABLE_SEL = ".pie-qti-associable";
|
|
29
|
-
export declare const ASSOCIATION_SEL = ".pie-qti-association";
|
|
30
|
-
export declare const CHOICES_SEL = ".pie-qti-choices";
|
|
31
|
-
export declare const CLICKED_SEL = ".pie-qti-clicked";
|
|
32
|
-
export declare const DRAGGING_SEL = ".pie-qti-dragging";
|
|
33
|
-
export declare const DRAGOVER_SEL = ".pie-qti-dragover";
|
|
34
|
-
export declare const GAP_IMG_SEL = "[data-pie-qti-tag=\"gapImg\"]";
|
|
35
|
-
export declare const GAP_SEL = ".pie-qti-gap";
|
|
36
|
-
export declare const GAP_TEXT_SEL = "[data-pie-qti-tag=\"gapText\"]";
|
|
37
|
-
export declare const GHOST_SEL = ".pie-qti-ghost";
|
|
38
|
-
export declare const HOTSPOT_SEL = ".pie-qti-hotspot";
|
|
39
|
-
export declare const INTERACTION_SEL = ".pie-qti-interaction";
|
|
40
|
-
export declare const ITEM_SEL = "[data-pie-qti-tag=\"assessmentItem\"]";
|
|
41
|
-
export declare const SIMPLECHOICE_SEL = "[data-pie-qti-tag=\"simpleChoice\"]";
|
|
42
|
-
export declare const MSG_OK = "pie-qti-msg-ok";
|
|
43
|
-
export declare const MSG_NONE = "pie-qti-msg-none";
|
|
44
|
-
export declare const MSG_NO_SKIP = "pie-qti-msg-no-skip";
|
|
45
|
-
export declare const MSG_TOO_MANY = "pie-qti-msg-too-many";
|
|
46
|
-
export declare const MSG_TOO_FEW = "pie-qti-msg-too-few";
|
|
47
|
-
export declare const MSG_MISMATCH = "pie-qti-msg-match-not-allowed";
|
|
48
|
-
/**
|
|
49
|
-
* QTI 2.2 Response Processing Templates namespace.
|
|
50
|
-
* Note: Template resolution is namespace-agnostic - only the template filename is used.
|
|
51
|
-
* Templates from v2p0, v2p1, and v2p2 namespaces are all supported.
|
|
52
|
-
*/
|
|
53
|
-
export declare const RPTEMPLATES = "http://www.imsglobal.org/question/qti_v2p2/rptemplates";
|
|
54
|
-
export declare const SVG_NS = "http://www.w3.org/2000/svg";
|
|
55
|
-
export declare const XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
56
|
-
export declare const XML_NS = "http://www.w3.org/XML/1998/namespace";
|
|
57
|
-
export declare const DEFAULT_THEME = "theme";
|
|
58
|
-
export declare const MAX_TABLE_COLS = 4;
|
|
59
|
-
export declare const EN: {
|
|
60
|
-
UPLOAD: string;
|
|
61
|
-
COMMENT: string;
|
|
62
|
-
EXPECTED_CHARS: (len: number) => string;
|
|
63
|
-
EXPECTED_LINES: (lines: number) => string;
|
|
64
|
-
END_TEST: string;
|
|
65
|
-
};
|
package/dist/core/constants.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* QTI constants and configuration
|
|
3
|
-
*/
|
|
4
|
-
// Prefix for data attributes and CSS classes
|
|
5
|
-
export const PREFIX = 'pie-qti';
|
|
6
|
-
// Data attributes
|
|
7
|
-
export const ID = `data-${PREFIX}-identifier`;
|
|
8
|
-
export const RESPONSE_ID = `data-${PREFIX}-response-identifier`;
|
|
9
|
-
export const TAG = `data-${PREFIX}-tag`;
|
|
10
|
-
export const NAVMODE = `data-${PREFIX}-navigation-mode`;
|
|
11
|
-
export const SHOWHIDE = `data-${PREFIX}-show-hide`;
|
|
12
|
-
// CSS class names
|
|
13
|
-
export const ANSWERED = `${PREFIX}-answered`;
|
|
14
|
-
export const ASSOCIABLE = `${PREFIX}-associable`;
|
|
15
|
-
export const ASSOCIATION = `${PREFIX}-association`;
|
|
16
|
-
export const CHOICES = `${PREFIX}-choices`;
|
|
17
|
-
export const CLICKED = `${PREFIX}-clicked`;
|
|
18
|
-
export const CURRENT = `${PREFIX}-current`;
|
|
19
|
-
export const DRAGGING = `${PREFIX}-dragging`;
|
|
20
|
-
export const DRAGOVER = `${PREFIX}-dragover`;
|
|
21
|
-
export const GAP = `${PREFIX}-gap`;
|
|
22
|
-
export const GHOST = `${PREFIX}-ghost`;
|
|
23
|
-
export const HOTSPOT = `${PREFIX}-hotspot`;
|
|
24
|
-
export const INTERACTION = `${PREFIX}-interaction`;
|
|
25
|
-
export const MATCH = `${PREFIX}-match`;
|
|
26
|
-
export const MATCHED = `${PREFIX}-matched`;
|
|
27
|
-
export const MODAL = `${PREFIX}-modal`;
|
|
28
|
-
export const NAVIGATION = `${PREFIX}-navigation`;
|
|
29
|
-
export const PIVOTABLE = `${PREFIX}-pivotable`;
|
|
30
|
-
export const SELECTED = `${PREFIX}-selected`;
|
|
31
|
-
// CSS selectors
|
|
32
|
-
export const ASSOCIABLE_SEL = `.${ASSOCIABLE}`;
|
|
33
|
-
export const ASSOCIATION_SEL = `.${ASSOCIATION}`;
|
|
34
|
-
export const CHOICES_SEL = `.${CHOICES}`;
|
|
35
|
-
export const CLICKED_SEL = `.${CLICKED}`;
|
|
36
|
-
export const DRAGGING_SEL = `.${DRAGGING}`;
|
|
37
|
-
export const DRAGOVER_SEL = `.${DRAGOVER}`;
|
|
38
|
-
export const GAP_IMG_SEL = `[${TAG}="gapImg"]`;
|
|
39
|
-
export const GAP_SEL = `.${GAP}`;
|
|
40
|
-
export const GAP_TEXT_SEL = `[${TAG}="gapText"]`;
|
|
41
|
-
export const GHOST_SEL = `.${GHOST}`;
|
|
42
|
-
export const HOTSPOT_SEL = `.${HOTSPOT}`;
|
|
43
|
-
export const INTERACTION_SEL = `.${INTERACTION}`;
|
|
44
|
-
export const ITEM_SEL = `[${TAG}="assessmentItem"]`;
|
|
45
|
-
export const SIMPLECHOICE_SEL = `[${TAG}="simpleChoice"]`;
|
|
46
|
-
// Message identifiers
|
|
47
|
-
export const MSG_OK = `${PREFIX}-msg-ok`;
|
|
48
|
-
export const MSG_NONE = `${PREFIX}-msg-none`;
|
|
49
|
-
export const MSG_NO_SKIP = `${PREFIX}-msg-no-skip`;
|
|
50
|
-
export const MSG_TOO_MANY = `${PREFIX}-msg-too-many`;
|
|
51
|
-
export const MSG_TOO_FEW = `${PREFIX}-msg-too-few`;
|
|
52
|
-
export const MSG_MISMATCH = `${PREFIX}-msg-match-not-allowed`;
|
|
53
|
-
// Namespaces
|
|
54
|
-
/**
|
|
55
|
-
* QTI 2.2 Response Processing Templates namespace.
|
|
56
|
-
* Note: Template resolution is namespace-agnostic - only the template filename is used.
|
|
57
|
-
* Templates from v2p0, v2p1, and v2p2 namespaces are all supported.
|
|
58
|
-
*/
|
|
59
|
-
export const RPTEMPLATES = 'http://www.imsglobal.org/question/qti_v2p2/rptemplates';
|
|
60
|
-
export const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
61
|
-
export const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
62
|
-
export const XML_NS = 'http://www.w3.org/XML/1998/namespace';
|
|
63
|
-
// UI constants
|
|
64
|
-
export const DEFAULT_THEME = 'theme';
|
|
65
|
-
export const MAX_TABLE_COLS = 4;
|
|
66
|
-
// Localization (English defaults)
|
|
67
|
-
export const EN = {
|
|
68
|
-
UPLOAD: 'Upload file',
|
|
69
|
-
COMMENT: 'Comment on this question if you wish.',
|
|
70
|
-
EXPECTED_CHARS: (len) => `expected: ${len} chars`,
|
|
71
|
-
EXPECTED_LINES: (lines) => `expected: ${lines} lines`,
|
|
72
|
-
END_TEST: '<p>You have reached the end of the test</p>',
|
|
73
|
-
};
|
|
74
|
-
//# sourceMappingURL=constants.js.map
|