@pie-qti/item-player 0.1.25 → 0.1.26

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/dist/index.d.ts CHANGED
@@ -18,7 +18,8 @@ export { globalPerformanceMonitor, type PerformanceEntry, PerformanceMonitor, ty
18
18
  export { isResponseEmpty } from './utils/responseUtils.js';
19
19
  export type { PnpProfile } from './pnp/types.js';
20
20
  export { applyPnpToRoot } from './pnp/applyPnp.js';
21
- export { parsePnpXml } from './pnp/parsePnpXml.js';
21
+ export type { AfaPnpRecord } from './pnp/parsePnpXml.js';
22
+ export { AFA_PNP_NAMESPACE, parseAfaPnpXml, parsePnpXml, pnpProfileFromAfa } from './pnp/parsePnpXml.js';
22
23
  export type { CatalogIndex, CatalogCard, CatalogEntry } from './catalog/types.js';
23
24
  export { extractCatalog, extractCatalogFromItemXml, mergeCatalogs } from './catalog/catalogExtractor.js';
24
25
  export { getCatalogEntry } from './catalog/catalogLookup.js';
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ export * from './types/index.js';
20
20
  export { globalPerformanceMonitor, PerformanceMonitor, } from './utils/PerformanceMonitor.js';
21
21
  export { isResponseEmpty } from './utils/responseUtils.js';
22
22
  export { applyPnpToRoot } from './pnp/applyPnp.js';
23
- export { parsePnpXml } from './pnp/parsePnpXml.js';
23
+ export { AFA_PNP_NAMESPACE, parseAfaPnpXml, parsePnpXml, pnpProfileFromAfa } from './pnp/parsePnpXml.js';
24
24
  export { extractCatalog, extractCatalogFromItemXml, mergeCatalogs } from './catalog/catalogExtractor.js';
25
25
  export { getCatalogEntry } from './catalog/catalogLookup.js';
26
26
  export { PciLoadError, PciModuleResolverRequiredError } from './pci/types.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,4DAA4D;AAC5D,OAAO,EAGN,iBAAiB,EACjB,uBAAuB,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AGxB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;GAQG","sourcesContent":["/**\n * @pie-qti/item-player\n * Modern QTI player (2.2/3.0) - Framework-agnostic with web components\n */\n\n\n// Export web component registry for pluggable UI components\nexport {\n\ttype ComponentConfig,\n\ttype ComponentPlugin,\n\tComponentRegistry,\n\tcreateComponentRegistry,\n} from './core/ComponentRegistry.js';\nexport * from './core/constants.js';\n// Export drawing utilities\nexport * from './utils/drawingUtils.js';\nexport {\n\tcreateAssessmentItemDefinition,\n\ttype AssessmentItemDefinition,\n\ttype AssessmentItemDefinitionConfig,\n\ttype AssessmentItemDefinitionPlugin,\n} from './core/AssessmentItemDefinition.js';\nexport {\n\ttype ItemPresentationView,\n\ttype ItemSession,\n\ttype ItemSessionCommand,\n\ttype ItemSessionEventCommand,\n\ttype ItemSessionListener,\n\ttype ItemSessionTransition,\n\ttype ItemSessionView,\n\ttype OpenItemSessionOptions,\n} from './core/ItemSession.js';\nexport type {\n\tFinalItemBodyHtml,\n\tItemInteractionMount,\n\tItemPresentation,\n\tItemPresentationFlowNode,\n} from './presentation/itemPresentationPlan.js';\nexport { getRoleCapabilities, type RoleCapabilities } from './core/rolePolicy.js';\n// Render-facing interaction contracts. Standard extractors remain implementation details.\nexport type * from './interactions/shared/types.js';\nexport {\n\tcreateExtendedTextNumericRecord,\n\tcreateExtendedTextResponse,\n\tcreateExtendedTextStringResponse,\n\textendedTextResponseToStrings,\n\ttype ExtendedTextNumericRecord,\n\ttype ExtendedTextRecordField,\n} from './interactions/extended-text/response.js';\nexport type {\n\tElementExtractor,\n\tExtractionContext,\n\tExtractionDispatchResult,\n\tExtractionResult,\n\tExtractionUtils,\n\tInteractionDeliveryField,\n\tInteractionDeliveryPathSegment,\n\tInteractionDeliverySchema,\n\tValidationResult,\n\tVariableDeclaration,\n} from './extraction/index.js';\nexport {\n\tcreateExtractionContext,\n\tcreateExtractionRegistry,\n\tcreateExtractionUtils,\n\tExtractionError,\n\tExtractionRegistry,\n\thtmlField,\n\tisErrorResult,\n\tisSuccessResult,\n\turlField,\n} from './extraction/index.js';\n// NOTE:\n// The player’s primary rendering contract is via web components and the Svelte component entrypoint.\n// If you need non-web-component rendering, build it externally against the public extraction APIs.\n// Export all types including adaptive item types\nexport * from './types/index.js';\n// Export utilities\nexport {\n\tglobalPerformanceMonitor,\n\ttype PerformanceEntry,\n\tPerformanceMonitor,\n\ttype PerformanceMonitorConfig,\n\ttype PerformanceReport,\n} from './utils/PerformanceMonitor.js';\n\nexport { isResponseEmpty } from './utils/responseUtils.js';\n\n// PNP profile (QTI 3.0 §6.2)\nexport type { PnpProfile } from './pnp/types.js';\nexport { applyPnpToRoot } from './pnp/applyPnp.js';\nexport { parsePnpXml } from './pnp/parsePnpXml.js';\n\n// Catalog (QTI 3.0 §6.3)\nexport type { CatalogIndex, CatalogCard, CatalogEntry } from './catalog/types.js';\nexport { extractCatalog, extractCatalogFromItemXml, mergeCatalogs } from './catalog/catalogExtractor.js';\nexport { getCatalogEntry } from './catalog/catalogLookup.js';\nexport type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';\n\n// PCI — Portable Custom Interaction (QTI 3.0 §6.1)\nexport type {\n\tExtractedPci,\n\tPciBoundTo,\n\tPciConfiguration,\n\tPciHostController,\n\tPciHostOptions,\n\tPciModule,\n\tPciModulePathKind,\n\tPciModuleResolutionContext,\n\tPciModuleResolver,\n} from './pci/types.js';\nexport { PciLoadError, PciModuleResolverRequiredError } from './pci/types.js';\nexport { PciHost } from './pci/PciHost.js';\nexport {\n\tcreateAllowlistPciModuleResolver,\n\tPciModuleNotAllowedError,\n} from './pci/allowlistResolver.js';\nexport type { AllowlistPciResolverOptions } from './pci/allowlistResolver.js';\n\n// Re-export QTI heuristics from @pie-qti/ims-cp-core for convenience\n// (heuristics are now in the shared ingestion layer)\nexport {\n\tnormalizeHeuristicsConfig,\n\tapplyFeedbackTextHeuristics,\n\tshouldUseLenientImagePaths,\n\tshouldAutoPopulateFeedbackOutcome,\n\tDEFAULT_HEURISTICS_CONFIG,\n\tSTRICT_QTI_CONFIG,\n\tFEEDBACK_TEXT_TRANSFORMS,\n\ttype QtiHeuristicsConfig,\n\ttype TextTransform,\n} from '@pie-qti/ims-cp-core';\n\n/**\n * NOTE (SSR safety):\n * Web component base classes depend on DOM globals like `HTMLElement` and must not be\n * re-exported from the main entrypoint. Item ownership flows through\n * AssessmentItemDefinition and ItemSession in every deployment.\n *\n * Import web-components from the subpath entry instead:\n * - `@pie-qti/item-player/web-components`\n */\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,4DAA4D;AAC5D,OAAO,EAGN,iBAAiB,EACjB,uBAAuB,GACvB,MAAM,6BAA6B,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,2BAA2B;AAC3B,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACN,8BAA8B,GAI9B,MAAM,oCAAoC,CAAC;AAiB5C,OAAO,EAAE,mBAAmB,EAAyB,MAAM,sBAAsB,CAAC;AAGlF,OAAO,EACN,+BAA+B,EAC/B,0BAA0B,EAC1B,gCAAgC,EAChC,6BAA6B,GAG7B,MAAM,0CAA0C,CAAC;AAalD,OAAO,EACN,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,aAAa,EACb,eAAe,EACf,QAAQ,GACR,MAAM,uBAAuB,CAAC;AAC/B,QAAQ;AACR,qGAAqG;AACrG,mGAAmG;AACnG,iDAAiD;AACjD,cAAc,kBAAkB,CAAC;AACjC,mBAAmB;AACnB,OAAO,EACN,wBAAwB,EAExB,kBAAkB,GAGlB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAI3D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAIzG,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACzG,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAe7D,OAAO,EAAE,YAAY,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EACN,gCAAgC,EAChC,wBAAwB,GACxB,MAAM,4BAA4B,CAAC;AAGpC,qEAAqE;AACrE,qDAAqD;AACrD,OAAO,EACN,yBAAyB,EACzB,2BAA2B,EAC3B,0BAA0B,EAC1B,iCAAiC,EACjC,yBAAyB,EACzB,iBAAiB,EACjB,wBAAwB,GAGxB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;GAQG","sourcesContent":["/**\n * @pie-qti/item-player\n * Modern QTI player (2.2/3.0) - Framework-agnostic with web components\n */\n\n\n// Export web component registry for pluggable UI components\nexport {\n\ttype ComponentConfig,\n\ttype ComponentPlugin,\n\tComponentRegistry,\n\tcreateComponentRegistry,\n} from './core/ComponentRegistry.js';\nexport * from './core/constants.js';\n// Export drawing utilities\nexport * from './utils/drawingUtils.js';\nexport {\n\tcreateAssessmentItemDefinition,\n\ttype AssessmentItemDefinition,\n\ttype AssessmentItemDefinitionConfig,\n\ttype AssessmentItemDefinitionPlugin,\n} from './core/AssessmentItemDefinition.js';\nexport {\n\ttype ItemPresentationView,\n\ttype ItemSession,\n\ttype ItemSessionCommand,\n\ttype ItemSessionEventCommand,\n\ttype ItemSessionListener,\n\ttype ItemSessionTransition,\n\ttype ItemSessionView,\n\ttype OpenItemSessionOptions,\n} from './core/ItemSession.js';\nexport type {\n\tFinalItemBodyHtml,\n\tItemInteractionMount,\n\tItemPresentation,\n\tItemPresentationFlowNode,\n} from './presentation/itemPresentationPlan.js';\nexport { getRoleCapabilities, type RoleCapabilities } from './core/rolePolicy.js';\n// Render-facing interaction contracts. Standard extractors remain implementation details.\nexport type * from './interactions/shared/types.js';\nexport {\n\tcreateExtendedTextNumericRecord,\n\tcreateExtendedTextResponse,\n\tcreateExtendedTextStringResponse,\n\textendedTextResponseToStrings,\n\ttype ExtendedTextNumericRecord,\n\ttype ExtendedTextRecordField,\n} from './interactions/extended-text/response.js';\nexport type {\n\tElementExtractor,\n\tExtractionContext,\n\tExtractionDispatchResult,\n\tExtractionResult,\n\tExtractionUtils,\n\tInteractionDeliveryField,\n\tInteractionDeliveryPathSegment,\n\tInteractionDeliverySchema,\n\tValidationResult,\n\tVariableDeclaration,\n} from './extraction/index.js';\nexport {\n\tcreateExtractionContext,\n\tcreateExtractionRegistry,\n\tcreateExtractionUtils,\n\tExtractionError,\n\tExtractionRegistry,\n\thtmlField,\n\tisErrorResult,\n\tisSuccessResult,\n\turlField,\n} from './extraction/index.js';\n// NOTE:\n// The player’s primary rendering contract is via web components and the Svelte component entrypoint.\n// If you need non-web-component rendering, build it externally against the public extraction APIs.\n// Export all types including adaptive item types\nexport * from './types/index.js';\n// Export utilities\nexport {\n\tglobalPerformanceMonitor,\n\ttype PerformanceEntry,\n\tPerformanceMonitor,\n\ttype PerformanceMonitorConfig,\n\ttype PerformanceReport,\n} from './utils/PerformanceMonitor.js';\n\nexport { isResponseEmpty } from './utils/responseUtils.js';\n\n// PNP profile (AfA PNP 3.0, QTI 3's per-candidate profile)\nexport type { PnpProfile } from './pnp/types.js';\nexport { applyPnpToRoot } from './pnp/applyPnp.js';\nexport type { AfaPnpRecord } from './pnp/parsePnpXml.js';\nexport { AFA_PNP_NAMESPACE, parseAfaPnpXml, parsePnpXml, pnpProfileFromAfa } from './pnp/parsePnpXml.js';\n\n// Catalog (QTI 3.0 §6.3)\nexport type { CatalogIndex, CatalogCard, CatalogEntry } from './catalog/types.js';\nexport { extractCatalog, extractCatalogFromItemXml, mergeCatalogs } from './catalog/catalogExtractor.js';\nexport { getCatalogEntry } from './catalog/catalogLookup.js';\nexport type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';\n\n// PCI — Portable Custom Interaction (QTI 3.0 §6.1)\nexport type {\n\tExtractedPci,\n\tPciBoundTo,\n\tPciConfiguration,\n\tPciHostController,\n\tPciHostOptions,\n\tPciModule,\n\tPciModulePathKind,\n\tPciModuleResolutionContext,\n\tPciModuleResolver,\n} from './pci/types.js';\nexport { PciLoadError, PciModuleResolverRequiredError } from './pci/types.js';\nexport { PciHost } from './pci/PciHost.js';\nexport {\n\tcreateAllowlistPciModuleResolver,\n\tPciModuleNotAllowedError,\n} from './pci/allowlistResolver.js';\nexport type { AllowlistPciResolverOptions } from './pci/allowlistResolver.js';\n\n// Re-export QTI heuristics from @pie-qti/ims-cp-core for convenience\n// (heuristics are now in the shared ingestion layer)\nexport {\n\tnormalizeHeuristicsConfig,\n\tapplyFeedbackTextHeuristics,\n\tshouldUseLenientImagePaths,\n\tshouldAutoPopulateFeedbackOutcome,\n\tDEFAULT_HEURISTICS_CONFIG,\n\tSTRICT_QTI_CONFIG,\n\tFEEDBACK_TEXT_TRANSFORMS,\n\ttype QtiHeuristicsConfig,\n\ttype TextTransform,\n} from '@pie-qti/ims-cp-core';\n\n/**\n * NOTE (SSR safety):\n * Web component base classes depend on DOM globals like `HTMLElement` and must not be\n * re-exported from the main entrypoint. Item ownership flows through\n * AssessmentItemDefinition and ItemSession in every deployment.\n *\n * Import web-components from the subpath entry instead:\n * - `@pie-qti/item-player/web-components`\n */\n"]}
@@ -1,8 +1,38 @@
1
1
  import type { PnpProfile } from './types.js';
2
+ /** QTI 3's profile of Access for All Personal Needs and Preferences 3.0. */
3
+ export declare const AFA_PNP_NAMESPACE = "http://www.imsglobal.org/xsd/qtiv3p0/imsafa3p0pnp_v1p0";
2
4
  /**
3
- * Parse a QTI 3.0 <personalNeedsProfile> element (or legacy <pnp> element) into a PnpProfile.
5
+ * An AfA PNP 3.0 profile as JSON keyed by the spec's kebab-case terms, the shape
6
+ * pie-players' `createPersonalNeedsProfileFromAfa` takes.
4
7
  *
5
- * Accepts either an XML/HTML string containing the profile element, or a live DOM Element.
6
- * Unknown child elements are silently ignored for forward-compatibility.
8
+ * An empty element is `{}`, an element holding only text is that text (a number or
9
+ * boolean when it reads as one), `xml:lang` is `language`, a repeated element is an
10
+ * array, and a feature set is the list of feature names it holds. Elements of another
11
+ * namespace, AfA's extension mechanism, sit under `extensions` by local name.
12
+ */
13
+ export interface AfaPnpRecord {
14
+ 'activate-at-initialization-set'?: string[];
15
+ 'activate-as-option-set'?: string[];
16
+ 'prohibit-set'?: string[];
17
+ extensions?: Record<string, unknown>;
18
+ [feature: string]: unknown;
19
+ }
20
+ /**
21
+ * Parse an AfA PNP 3.0 document into its record: an `access-for-all-pnp` element, or
22
+ * the first one inside an `access-for-all-pnp-record`. A bulk records file holds one
23
+ * profile per candidate, so pass the candidate's record. Returns `null` when the input
24
+ * holds no profile.
25
+ */
26
+ export declare function parseAfaPnpXml(xml: string | Element): AfaPnpRecord | null;
27
+ /**
28
+ * The part of an AfA record the item player renders. A feature counts when the record
29
+ * names it or one of its activation sets lists it, unless `prohibit-set` lists it.
30
+ * Features with no `PnpProfile` field stay in the record for the host's tools:
31
+ * `fixed-minutes` testing time, `ext:` color themes, and every tool support.
32
+ */
33
+ export declare function pnpProfileFromAfa(record: AfaPnpRecord): PnpProfile;
34
+ /**
35
+ * Parse an AfA PNP 3.0 document into the `PnpProfile` the item player renders. Returns
36
+ * an empty profile when the input holds none. `parseAfaPnpXml` returns the whole record.
7
37
  */
8
38
  export declare function parsePnpXml(xml: string | Element): PnpProfile;
@@ -1,190 +1,241 @@
1
1
  import { parse as parseHtml } from 'node-html-parser';
2
+ /** QTI 3's profile of Access for All Personal Needs and Preferences 3.0. */
3
+ export const AFA_PNP_NAMESPACE = 'http://www.imsglobal.org/xsd/qtiv3p0/imsafa3p0pnp_v1p0';
4
+ const FEATURE_SETS = new Set(['activate-at-initialization-set', 'activate-as-option-set', 'prohibit-set']);
2
5
  /**
3
- * Parse a QTI 3.0 <personalNeedsProfile> element (or legacy <pnp> element) into a PnpProfile.
4
- *
5
- * Accepts either an XML/HTML string containing the profile element, or a live DOM Element.
6
- * Unknown child elements are silently ignored for forward-compatibility.
6
+ * QTI 3's predefined catalog card supports, less `glossary-on-screen` and
7
+ * `keyword-translation`, which have popups of their own. A granted one enables the
8
+ * catalog support of that name.
7
9
  */
8
- export function parsePnpXml(xml) {
9
- if (typeof xml !== 'string') {
10
- // Live DOM Element — serialise to string and re-parse via node-html-parser
11
- return parsePnpXml(xml.outerHTML ?? '');
12
- }
13
- const trimmed = xml.trim();
10
+ const CATALOG_SUPPORT_FEATURES = [
11
+ 'additional-directions',
12
+ 'audio-description',
13
+ 'braille',
14
+ 'high-contrast',
15
+ 'keyboard-directions',
16
+ 'linguistic-guidance',
17
+ 'long-description',
18
+ 'sign-language',
19
+ 'simplified-graphics',
20
+ 'simplified-language-portions',
21
+ 'spoken',
22
+ 'tactile',
23
+ 'transcript',
24
+ ];
25
+ /** The extension SBAC requests its illustrated glossary with. */
26
+ const ILLUSTRATED_GLOSSARY_EXTENSION = 'sbac-glossary-illustration';
27
+ /**
28
+ * AfA `color-theme` terms onto the player's scheme names. The spec leaves a theme's
29
+ * exact colors to the delivery system, so `high-contrast` takes black on white and
30
+ * its reverse white on black.
31
+ */
32
+ const COLOR_THEMES = {
33
+ default: 'default',
34
+ 'default-reverse': 'defaultreverse',
35
+ 'high-contrast': 'blackwhite',
36
+ 'high-contrast-reverse': 'whiteblack',
37
+ 'black-rose': 'blackrose',
38
+ 'rose-black': 'roseblack',
39
+ 'yellow-blue': 'yellowblue',
40
+ 'blue-yellow': 'blueyellow',
41
+ 'medgray-darkgray': 'mgraydgray',
42
+ 'darkgray-medgray': 'dgraymgray',
43
+ 'black-cyan': 'blackcyan',
44
+ 'cyan-black': 'cyanblack',
45
+ 'black-cream': 'blackcream',
46
+ 'cream-black': 'creamblack',
47
+ };
48
+ /**
49
+ * Parse an AfA PNP 3.0 document into its record: an `access-for-all-pnp` element, or
50
+ * the first one inside an `access-for-all-pnp-record`. A bulk records file holds one
51
+ * profile per candidate, so pass the candidate's record. Returns `null` when the input
52
+ * holds no profile.
53
+ */
54
+ export function parseAfaPnpXml(xml) {
55
+ const source = typeof xml === 'string' ? xml : (xml.outerHTML ?? '');
56
+ const trimmed = source.replace(/<\?xml[^>]*\?>/g, '').trim();
14
57
  if (!trimmed)
15
- return {};
16
- // Wrap so node-html-parser treats the outer tag as the root
17
- const doc = parseHtml(`<root>${trimmed}</root>`, { lowerCaseTagName: true });
18
- const root = doc.querySelector('personalneedsprofile') ?? doc.querySelector('pnp');
58
+ return null;
59
+ const doc = parseHtml(`<root>${trimmed}</root>`, { lowerCaseTagName: false });
60
+ const root = findProfile(doc);
19
61
  if (!root)
20
- return {};
21
- return extractProfile(root);
22
- }
23
- function extractProfile(root) {
24
- var _a, _b;
25
- const profile = {};
26
- // <display>
27
- const displayEl = findChild(root, ['display']);
28
- if (displayEl) {
29
- profile.display = {};
30
- const colorSchemeEl = findChild(displayEl, ['colorscheme', 'color-scheme']);
31
- if (colorSchemeEl) {
32
- const val = (colorSchemeEl.getAttribute('value') ?? colorSchemeEl.text ?? '').trim().toLowerCase();
33
- if (isColorScheme(val))
34
- profile.display.colorScheme = val;
35
- }
36
- const magEl = findChild(displayEl, ['magnification']);
37
- if (magEl) {
38
- const val = parseFloat(magEl.getAttribute('value') ?? magEl.text ?? '');
39
- if (Number.isFinite(val) && val > 0)
40
- profile.display.magnification = val;
41
- }
42
- }
43
- // <content>
44
- const contentEl = findChild(root, ['content']);
45
- if (contentEl) {
46
- profile.content = {};
47
- const glossaryEl = findChild(contentEl, ['glossaryonscreen', 'glossary-on-screen']);
48
- if (glossaryEl) {
49
- profile.content.glossaryOnScreen = parseBool(glossaryEl.getAttribute('enabled') ?? glossaryEl.text ?? 'true');
50
- }
51
- const kwEl = findChild(contentEl, ['keywordtranslation', 'keyword-translation']);
52
- if (kwEl) {
53
- const active = parseBool(kwEl.getAttribute('active') ?? 'true');
54
- const languageCode = (kwEl.getAttribute('languagecode') ?? kwEl.getAttribute('language-code') ?? kwEl.getAttribute('lang') ?? '').trim();
55
- if (languageCode)
56
- profile.content.keywordTranslation = { active, languageCode };
57
- }
58
- const illustratedEl = findChild(contentEl, [
59
- 'illustratedglossary',
60
- 'illustrated-glossary',
61
- 'ext:sbacglossaryillustration',
62
- 'ext:sbac-glossary-illustration',
63
- ]);
64
- if (illustratedEl) {
65
- profile.content.illustratedGlossary = parseBool(illustratedEl.getAttribute('enabled') ?? illustratedEl.getAttribute('active') ?? illustratedEl.text ?? 'true');
66
- }
67
- const catalogSupportMap = [
68
- ['ttsPronunciation', ['ttspronunciation', 'tts-pronunciation']],
69
- ['signingDefinition', ['signingdefinition', 'signing-definition']],
70
- ['brailleText', ['brailletext', 'braille-text']],
71
- ['audioDescription', ['audiodescription', 'audio-description']],
72
- ['extendedDescription', ['extendeddescription', 'extended-description']],
73
- ];
74
- for (const [key, names] of catalogSupportMap) {
75
- const el = findChild(contentEl, names);
76
- if (el) {
77
- (_a = profile.content).catalogSupports ?? (_a.catalogSupports = {});
78
- profile.content.catalogSupports[key] = parseCatalogSupportPreference(el);
79
- }
62
+ return null;
63
+ const afaPrefixes = collectAfaPrefixes(root);
64
+ const record = {};
65
+ for (const child of elementChildren(root)) {
66
+ const { prefix, local } = splitName(child.rawTagName);
67
+ if (prefix && !afaPrefixes.has(prefix)) {
68
+ record.extensions ?? (record.extensions = {});
69
+ addValue(record.extensions, local, elementValue(child));
80
70
  }
81
- for (const el of findChildren(contentEl, ['catalogsupport', 'catalog-support', 'qti-catalog-support'])) {
82
- const usage = normalizeCatalogUsage(el.getAttribute('usage') ?? el.getAttribute('support') ?? el.getAttribute('name') ?? '');
83
- if (!usage)
84
- continue;
85
- const key = catalogSupportPreferenceKey(usage);
86
- (_b = profile.content).catalogSupports ?? (_b.catalogSupports = {});
87
- profile.content.catalogSupports[key] = parseCatalogSupportPreference(el);
71
+ else if (FEATURE_SETS.has(local)) {
72
+ record[local] = elementChildren(child).map((feature) => splitName(feature.rawTagName).local);
88
73
  }
89
- const etEl = findChild(contentEl, ['extendedtime', 'extended-time']);
90
- if (etEl) {
91
- const active = parseBool(etEl.getAttribute('active') ?? 'true');
92
- const rawMultiplier = etEl.getAttribute('multiplier') ?? etEl.text ?? '';
93
- const multiplier = rawMultiplier.trim().toLowerCase() === 'infinity'
94
- ? Infinity
95
- : parseFloat(rawMultiplier);
96
- if (Number.isFinite(multiplier) || multiplier === Infinity) {
97
- profile.content.extendedTime = { active, multiplier };
98
- }
74
+ else {
75
+ addValue(record, local, elementValue(child));
99
76
  }
100
77
  }
101
- // <cognitive>
102
- const cogEl = findChild(root, ['cognitive']);
103
- if (cogEl) {
104
- profile.cognitive = {};
105
- const elTool = findChild(cogEl, ['eliminationtool', 'elimination-tool']);
106
- if (elTool) {
107
- profile.cognitive.eliminationTool = parseBool(elTool.getAttribute('enabled') ?? elTool.getAttribute('active') ?? elTool.text ?? 'true');
108
- }
78
+ return record;
79
+ }
80
+ /**
81
+ * The part of an AfA record the item player renders. A feature counts when the record
82
+ * names it or one of its activation sets lists it, unless `prohibit-set` lists it.
83
+ * Features with no `PnpProfile` field stay in the record for the host's tools:
84
+ * `fixed-minutes` testing time, `ext:` color themes, and every tool support.
85
+ */
86
+ export function pnpProfileFromAfa(record) {
87
+ const prohibited = new Set(record['prohibit-set'] ?? []);
88
+ const listed = new Set([
89
+ ...(record['activate-at-initialization-set'] ?? []),
90
+ ...(record['activate-as-option-set'] ?? []),
91
+ ]);
92
+ const granted = (feature) => !prohibited.has(feature) && (isPresent(record[feature]) || listed.has(feature));
93
+ const display = {};
94
+ const theme = granted('text-appearance')
95
+ ? field(record['text-appearance'], 'color-theme')
96
+ : granted('color-theme')
97
+ ? record['color-theme']
98
+ : undefined;
99
+ if (typeof theme === 'string' && COLOR_THEMES[theme])
100
+ display.colorScheme = COLOR_THEMES[theme];
101
+ if (granted('magnification')) {
102
+ const magnification = record.magnification;
103
+ const zoom = finiteNumber(field(field(magnification, 'all-content'), 'zoom-amount')) ??
104
+ finiteNumber(field(field(magnification, 'text'), 'zoom-amount'));
105
+ if (zoom !== undefined && zoom > 0)
106
+ display.magnification = zoom;
107
+ }
108
+ const content = {};
109
+ if (granted('glossary-on-screen'))
110
+ content.glossaryOnScreen = true;
111
+ if (granted('keyword-translation')) {
112
+ const languageCode = normalizeLanguageCode(field(record['keyword-translation'], 'language'));
113
+ if (languageCode)
114
+ content.keywordTranslation = { active: true, languageCode };
115
+ }
116
+ if (!prohibited.has(ILLUSTRATED_GLOSSARY_EXTENSION) &&
117
+ isPresent(record.extensions?.[ILLUSTRATED_GLOSSARY_EXTENSION])) {
118
+ content.illustratedGlossary = true;
109
119
  }
120
+ for (const feature of CATALOG_SUPPORT_FEATURES) {
121
+ if (!granted(feature))
122
+ continue;
123
+ const languageCode = normalizeLanguageCode(field(record[feature], 'language'));
124
+ const preference = languageCode ? { active: true, languageCode } : true;
125
+ content.catalogSupports ?? (content.catalogSupports = {});
126
+ content.catalogSupports[feature] = preference;
127
+ }
128
+ if (granted('additional-testing-time')) {
129
+ const testingTime = record['additional-testing-time'];
130
+ const multiplier = isPresent(field(testingTime, 'unlimited'))
131
+ ? Infinity
132
+ : finiteNumber(field(testingTime, 'time-multiplier'));
133
+ if (multiplier !== undefined && multiplier > 0)
134
+ content.extendedTime = { active: true, multiplier };
135
+ }
136
+ const cognitive = {};
137
+ if (granted('answer-masking'))
138
+ cognitive.eliminationTool = true;
139
+ const profile = {};
140
+ if (Object.keys(display).length > 0)
141
+ profile.display = display;
142
+ if (Object.keys(content).length > 0)
143
+ profile.content = content;
144
+ if (Object.keys(cognitive).length > 0)
145
+ profile.cognitive = cognitive;
110
146
  return profile;
111
147
  }
148
+ /**
149
+ * Parse an AfA PNP 3.0 document into the `PnpProfile` the item player renders. Returns
150
+ * an empty profile when the input holds none. `parseAfaPnpXml` returns the whole record.
151
+ */
152
+ export function parsePnpXml(xml) {
153
+ const record = parseAfaPnpXml(xml);
154
+ return record ? pnpProfileFromAfa(record) : {};
155
+ }
112
156
  // ---------------------------------------------------------------------------
113
157
  // Helpers
114
158
  // ---------------------------------------------------------------------------
115
- function findChild(parent, names) {
116
- return findChildren(parent, names)[0] ?? null;
159
+ function findProfile(parent) {
160
+ for (const child of elementChildren(parent)) {
161
+ if (splitName(child.rawTagName).local === 'access-for-all-pnp')
162
+ return child;
163
+ const nested = findProfile(child);
164
+ if (nested)
165
+ return nested;
166
+ }
167
+ return null;
117
168
  }
118
- function findChildren(parent, names) {
119
- const matches = [];
120
- for (const child of parent.childNodes) {
121
- if (child.nodeType !== 1)
122
- continue; // element nodes only
123
- const el = child;
124
- const tag = (el.rawTagName ?? '').toLowerCase();
125
- if (names.includes(tag))
126
- matches.push(el);
169
+ /** Prefixes bound to an AfA PNP namespace on the profile or its ancestors. */
170
+ function collectAfaPrefixes(root) {
171
+ const prefixes = new Set();
172
+ for (let el = root; el; el = el.parentNode) {
173
+ for (const [name, value] of Object.entries(el.rawAttributes ?? {})) {
174
+ if (name.startsWith('xmlns:') && value.includes('imsafa3p0pnp'))
175
+ prefixes.add(name.slice(6));
176
+ }
127
177
  }
128
- return matches;
178
+ return prefixes;
129
179
  }
130
- function parseBool(value) {
131
- const v = (value ?? '').trim().toLowerCase();
132
- return v !== 'false' && v !== '0' && v !== 'no';
180
+ function elementChildren(parent) {
181
+ return parent.childNodes.filter((child) => child.nodeType === 1);
133
182
  }
134
- function parseCatalogSupportPreference(el) {
135
- const active = parseBool(el.getAttribute('enabled') ?? el.getAttribute('active') ?? el.text ?? 'true');
136
- const languageCode = normalizeLanguageCode(el.getAttribute('languagecode') ?? el.getAttribute('language-code') ?? el.getAttribute('lang') ?? '');
137
- return languageCode ? { active, languageCode } : active;
183
+ function splitName(name) {
184
+ const raw = name ?? '';
185
+ const colon = raw.indexOf(':');
186
+ return colon < 0 ? { local: raw } : { prefix: raw.slice(0, colon), local: raw.slice(colon + 1) };
138
187
  }
139
- const COLOR_SCHEMES = new Set([
140
- 'default',
141
- 'defaultreverse',
142
- 'blackwhite',
143
- 'whiteblack',
144
- 'blackrose',
145
- 'roseblack',
146
- 'yellowblue',
147
- 'blueyellow',
148
- 'mgraydgray',
149
- 'dgraymgray',
150
- 'blackcyan',
151
- 'cyanblack',
152
- 'blackcream',
153
- 'creamblack',
154
- 'whitenav',
155
- 'medgray',
156
- ]);
157
- function isColorScheme(v) {
158
- return COLOR_SCHEMES.has(v);
188
+ function elementValue(el) {
189
+ const value = {};
190
+ for (const [name, raw] of Object.entries(el.rawAttributes ?? {})) {
191
+ if (name === 'xmlns' || name.startsWith('xmlns:') || name.startsWith('xsi:'))
192
+ continue;
193
+ addValue(value, name === 'xml:lang' ? 'language' : splitName(name).local, scalar(raw));
194
+ }
195
+ const children = elementChildren(el);
196
+ for (const child of children) {
197
+ addValue(value, splitName(child.rawTagName).local, elementValue(child));
198
+ }
199
+ if (children.length > 0 || Object.keys(value).length > 0)
200
+ return value;
201
+ const text = el.text.trim();
202
+ return text ? scalar(text) : {};
159
203
  }
160
- function normalizeCatalogUsage(value) {
161
- const usage = value.trim().toLowerCase();
162
- if (!/^[a-z][a-z0-9._-]*$/.test(usage))
163
- return null;
164
- return usage;
204
+ function addValue(target, key, value) {
205
+ if (!(key in target)) {
206
+ target[key] = value;
207
+ return;
208
+ }
209
+ const existing = target[key];
210
+ target[key] = Array.isArray(existing) ? [...existing, value] : [existing, value];
211
+ }
212
+ function scalar(raw) {
213
+ const value = raw.trim();
214
+ if (value === 'true')
215
+ return true;
216
+ if (value === 'false')
217
+ return false;
218
+ if (/^-?\d+(?:\.\d+)?$/.test(value))
219
+ return Number(value);
220
+ return value;
221
+ }
222
+ function field(value, key) {
223
+ return typeof value === 'object' && value !== null && !Array.isArray(value)
224
+ ? value[key]
225
+ : undefined;
226
+ }
227
+ function isPresent(value) {
228
+ return value !== undefined && value !== null && value !== false;
229
+ }
230
+ function finiteNumber(value) {
231
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
165
232
  }
166
233
  function normalizeLanguageCode(value) {
167
- const languageCode = value.trim();
168
- if (!languageCode)
234
+ if (typeof value !== 'string')
169
235
  return undefined;
236
+ const languageCode = value.trim();
170
237
  if (!/^[a-zA-Z]{2,8}(?:-[a-zA-Z0-9]{1,8})*$/.test(languageCode))
171
238
  return undefined;
172
239
  return languageCode;
173
240
  }
174
- function catalogSupportPreferenceKey(usage) {
175
- switch (usage) {
176
- case 'tts-pronunciation':
177
- return 'ttsPronunciation';
178
- case 'signing-definition':
179
- return 'signingDefinition';
180
- case 'braille-text':
181
- return 'brailleText';
182
- case 'audio-description':
183
- return 'audioDescription';
184
- case 'extended-description':
185
- return 'extendedDescription';
186
- default:
187
- return usage;
188
- }
189
- }
190
241
  //# sourceMappingURL=parsePnpXml.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parsePnpXml.js","sourceRoot":"","sources":["../../src/pnp/parsePnpXml.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAItD;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,GAAqB;IAChD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC7B,2EAA2E;QAC3E,OAAO,WAAW,CAAE,GAAe,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAExB,4DAA4D;IAC5D,MAAM,GAAG,GAAG,SAAS,CAAC,SAAS,OAAO,SAAS,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7E,MAAM,IAAI,GAAG,GAAG,CAAC,aAAa,CAAC,sBAAsB,CAAC,IAAI,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACnF,IAAI,CAAC,IAAI;QAAE,OAAO,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C;IACf,CAAC;AACF,CAAC","sourcesContent":["import { parse as parseHtml } from 'node-html-parser';\nimport type { HTMLElement as NhpElement } from 'node-html-parser';\nimport type { CatalogSupportPreference, PnpProfile } from './types.js';\n\n/**\n * Parse a QTI 3.0 <personalNeedsProfile> element (or legacy <pnp> element) into a PnpProfile.\n *\n * Accepts either an XML/HTML string containing the profile element, or a live DOM Element.\n * Unknown child elements are silently ignored for forward-compatibility.\n */\nexport function parsePnpXml(xml: string | Element): PnpProfile {\n\tif (typeof xml !== 'string') {\n\t\t// Live DOM Element — serialise to string and re-parse via node-html-parser\n\t\treturn parsePnpXml((xml as Element).outerHTML ?? '');\n\t}\n\n\tconst trimmed = xml.trim();\n\tif (!trimmed) return {};\n\n\t// Wrap so node-html-parser treats the outer tag as the root\n\tconst doc = parseHtml(`<root>${trimmed}</root>`, { lowerCaseTagName: true });\n\tconst root = doc.querySelector('personalneedsprofile') ?? doc.querySelector('pnp');\n\tif (!root) return {};\n\n\treturn extractProfile(root);\n}\n\nfunction extractProfile(root: NhpElement): PnpProfile {\n\tconst profile: PnpProfile = {};\n\n\t// <display>\n\tconst displayEl = findChild(root, ['display']);\n\tif (displayEl) {\n\t\tprofile.display = {};\n\n\t\tconst colorSchemeEl = findChild(displayEl, ['colorscheme', 'color-scheme']);\n\t\tif (colorSchemeEl) {\n\t\t\tconst val = (colorSchemeEl.getAttribute('value') ?? colorSchemeEl.text ?? '').trim().toLowerCase();\n\t\t\tif (isColorScheme(val)) profile.display.colorScheme = val;\n\t\t}\n\n\t\tconst magEl = findChild(displayEl, ['magnification']);\n\t\tif (magEl) {\n\t\t\tconst val = parseFloat(magEl.getAttribute('value') ?? magEl.text ?? '');\n\t\t\tif (Number.isFinite(val) && val > 0) profile.display.magnification = val;\n\t\t}\n\t}\n\n\t// <content>\n\tconst contentEl = findChild(root, ['content']);\n\tif (contentEl) {\n\t\tprofile.content = {};\n\n\t\tconst glossaryEl = findChild(contentEl, ['glossaryonscreen', 'glossary-on-screen']);\n\t\tif (glossaryEl) {\n\t\t\tprofile.content.glossaryOnScreen = parseBool(glossaryEl.getAttribute('enabled') ?? glossaryEl.text ?? 'true');\n\t\t}\n\n\t\tconst kwEl = findChild(contentEl, ['keywordtranslation', 'keyword-translation']);\n\t\tif (kwEl) {\n\t\t\tconst active = parseBool(kwEl.getAttribute('active') ?? 'true');\n\t\t\tconst languageCode = (kwEl.getAttribute('languagecode') ?? kwEl.getAttribute('language-code') ?? kwEl.getAttribute('lang') ?? '').trim();\n\t\t\tif (languageCode) profile.content.keywordTranslation = { active, languageCode };\n\t\t}\n\n\t\tconst illustratedEl = findChild(contentEl, [\n\t\t\t'illustratedglossary',\n\t\t\t'illustrated-glossary',\n\t\t\t'ext:sbacglossaryillustration',\n\t\t\t'ext:sbac-glossary-illustration',\n\t\t]);\n\t\tif (illustratedEl) {\n\t\t\tprofile.content.illustratedGlossary = parseBool(\n\t\t\t\tillustratedEl.getAttribute('enabled') ?? illustratedEl.getAttribute('active') ?? illustratedEl.text ?? 'true'\n\t\t\t);\n\t\t}\n\n\t\tconst catalogSupportMap = [\n\t\t\t['ttsPronunciation', ['ttspronunciation', 'tts-pronunciation']],\n\t\t\t['signingDefinition', ['signingdefinition', 'signing-definition']],\n\t\t\t['brailleText', ['brailletext', 'braille-text']],\n\t\t\t['audioDescription', ['audiodescription', 'audio-description']],\n\t\t\t['extendedDescription', ['extendeddescription', 'extended-description']],\n\t\t] as const;\n\t\tfor (const [key, names] of catalogSupportMap) {\n\t\t\tconst el = findChild(contentEl, names);\n\t\t\tif (el) {\n\t\t\t\tprofile.content.catalogSupports ??= {};\n\t\t\t\tprofile.content.catalogSupports[key] = parseCatalogSupportPreference(el);\n\t\t\t}\n\t\t}\n\n\t\tfor (const el of findChildren(contentEl, ['catalogsupport', 'catalog-support', 'qti-catalog-support'])) {\n\t\t\tconst usage = normalizeCatalogUsage(\n\t\t\t\tel.getAttribute('usage') ?? el.getAttribute('support') ?? el.getAttribute('name') ?? ''\n\t\t\t);\n\t\t\tif (!usage) continue;\n\t\t\tconst key = catalogSupportPreferenceKey(usage);\n\t\t\tprofile.content.catalogSupports ??= {};\n\t\t\tprofile.content.catalogSupports[key] = parseCatalogSupportPreference(el);\n\t\t}\n\n\t\tconst etEl = findChild(contentEl, ['extendedtime', 'extended-time']);\n\t\tif (etEl) {\n\t\t\tconst active = parseBool(etEl.getAttribute('active') ?? 'true');\n\t\t\tconst rawMultiplier = etEl.getAttribute('multiplier') ?? etEl.text ?? '';\n\t\t\tconst multiplier = rawMultiplier.trim().toLowerCase() === 'infinity'\n\t\t\t\t? Infinity\n\t\t\t\t: parseFloat(rawMultiplier);\n\t\t\tif (Number.isFinite(multiplier) || multiplier === Infinity) {\n\t\t\t\tprofile.content.extendedTime = { active, multiplier };\n\t\t\t}\n\t\t}\n\t}\n\n\t// <cognitive>\n\tconst cogEl = findChild(root, ['cognitive']);\n\tif (cogEl) {\n\t\tprofile.cognitive = {};\n\n\t\tconst elTool = findChild(cogEl, ['eliminationtool', 'elimination-tool']);\n\t\tif (elTool) {\n\t\t\tprofile.cognitive.eliminationTool = parseBool(\n\t\t\t\telTool.getAttribute('enabled') ?? elTool.getAttribute('active') ?? elTool.text ?? 'true'\n\t\t\t);\n\t\t}\n\t}\n\n\treturn profile;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction findChild(parent: NhpElement, names: readonly string[]): NhpElement | null {\n\treturn findChildren(parent, names)[0] ?? null;\n}\n\nfunction findChildren(parent: NhpElement, names: readonly string[]): NhpElement[] {\n\tconst matches: NhpElement[] = [];\n\tfor (const child of parent.childNodes) {\n\t\tif (child.nodeType !== 1) continue; // element nodes only\n\t\tconst el = child as NhpElement;\n\t\tconst tag = (el.rawTagName ?? '').toLowerCase();\n\t\tif (names.includes(tag)) matches.push(el);\n\t}\n\treturn matches;\n}\n\nfunction parseBool(value: string): boolean {\n\tconst v = (value ?? '').trim().toLowerCase();\n\treturn v !== 'false' && v !== '0' && v !== 'no';\n}\n\nfunction parseCatalogSupportPreference(el: NhpElement): CatalogSupportPreference {\n\tconst active = parseBool(el.getAttribute('enabled') ?? el.getAttribute('active') ?? el.text ?? 'true');\n\tconst languageCode = normalizeLanguageCode(\n\t\tel.getAttribute('languagecode') ?? el.getAttribute('language-code') ?? el.getAttribute('lang') ?? ''\n\t);\n\treturn languageCode ? { active, languageCode } : active;\n}\n\ntype ColorScheme = PnpProfile['display'] extends { colorScheme?: infer C } ? Exclude<C, undefined> : never;\nconst COLOR_SCHEMES = new Set<string>([\n\t'default',\n\t'defaultreverse',\n\t'blackwhite',\n\t'whiteblack',\n\t'blackrose',\n\t'roseblack',\n\t'yellowblue',\n\t'blueyellow',\n\t'mgraydgray',\n\t'dgraymgray',\n\t'blackcyan',\n\t'cyanblack',\n\t'blackcream',\n\t'creamblack',\n\t'whitenav',\n\t'medgray',\n]);\nfunction isColorScheme(v: string): v is ColorScheme {\n\treturn COLOR_SCHEMES.has(v);\n}\n\nfunction normalizeCatalogUsage(value: string): string | null {\n\tconst usage = value.trim().toLowerCase();\n\tif (!/^[a-z][a-z0-9._-]*$/.test(usage)) return null;\n\treturn usage;\n}\n\nfunction normalizeLanguageCode(value: string): string | undefined {\n\tconst languageCode = value.trim();\n\tif (!languageCode) return undefined;\n\tif (!/^[a-zA-Z]{2,8}(?:-[a-zA-Z0-9]{1,8})*$/.test(languageCode)) return undefined;\n\treturn languageCode;\n}\n\nfunction catalogSupportPreferenceKey(usage: string): string {\n\tswitch (usage) {\n\t\tcase 'tts-pronunciation':\n\t\t\treturn 'ttsPronunciation';\n\t\tcase 'signing-definition':\n\t\t\treturn 'signingDefinition';\n\t\tcase 'braille-text':\n\t\t\treturn 'brailleText';\n\t\tcase 'audio-description':\n\t\t\treturn 'audioDescription';\n\t\tcase 'extended-description':\n\t\t\treturn 'extendedDescription';\n\t\tdefault:\n\t\t\treturn usage;\n\t}\n}\n"]}
1
+ {"version":3,"file":"parsePnpXml.js","sourceRoot":"","sources":["../../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KAAc;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChD,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAClC,IAAI,CAAC,uCAAuC,CAAC,IAAI,CAAC,YAAY,CAAC;QAAE,OAAO,SAAS,CAAC;IAClF,OAAO,YAAY,CAAC;AACrB,CAAC","sourcesContent":["import { parse as parseHtml } from 'node-html-parser';\nimport type { HTMLElement as NhpElement } from 'node-html-parser';\nimport type { CatalogSupportPreference, PnpProfile } from './types.js';\n\n/** QTI 3's profile of Access for All Personal Needs and Preferences 3.0. */\nexport const AFA_PNP_NAMESPACE = 'http://www.imsglobal.org/xsd/qtiv3p0/imsafa3p0pnp_v1p0';\n\n/**\n * An AfA PNP 3.0 profile as JSON keyed by the spec's kebab-case terms, the shape\n * pie-players' `createPersonalNeedsProfileFromAfa` takes.\n *\n * An empty element is `{}`, an element holding only text is that text (a number or\n * boolean when it reads as one), `xml:lang` is `language`, a repeated element is an\n * array, and a feature set is the list of feature names it holds. Elements of another\n * namespace, AfA's extension mechanism, sit under `extensions` by local name.\n */\nexport interface AfaPnpRecord {\n\t'activate-at-initialization-set'?: string[];\n\t'activate-as-option-set'?: string[];\n\t'prohibit-set'?: string[];\n\textensions?: Record<string, unknown>;\n\t[feature: string]: unknown;\n}\n\nconst FEATURE_SETS = new Set(['activate-at-initialization-set', 'activate-as-option-set', 'prohibit-set']);\n\n/**\n * QTI 3's predefined catalog card supports, less `glossary-on-screen` and\n * `keyword-translation`, which have popups of their own. A granted one enables the\n * catalog support of that name.\n */\nconst CATALOG_SUPPORT_FEATURES = [\n\t'additional-directions',\n\t'audio-description',\n\t'braille',\n\t'high-contrast',\n\t'keyboard-directions',\n\t'linguistic-guidance',\n\t'long-description',\n\t'sign-language',\n\t'simplified-graphics',\n\t'simplified-language-portions',\n\t'spoken',\n\t'tactile',\n\t'transcript',\n] as const;\n\n/** The extension SBAC requests its illustrated glossary with. */\nconst ILLUSTRATED_GLOSSARY_EXTENSION = 'sbac-glossary-illustration';\n\ntype ColorScheme = NonNullable<NonNullable<PnpProfile['display']>['colorScheme']>;\n\n/**\n * AfA `color-theme` terms onto the player's scheme names. The spec leaves a theme's\n * exact colors to the delivery system, so `high-contrast` takes black on white and\n * its reverse white on black.\n */\nconst COLOR_THEMES: Readonly<Record<string, ColorScheme>> = {\n\tdefault: 'default',\n\t'default-reverse': 'defaultreverse',\n\t'high-contrast': 'blackwhite',\n\t'high-contrast-reverse': 'whiteblack',\n\t'black-rose': 'blackrose',\n\t'rose-black': 'roseblack',\n\t'yellow-blue': 'yellowblue',\n\t'blue-yellow': 'blueyellow',\n\t'medgray-darkgray': 'mgraydgray',\n\t'darkgray-medgray': 'dgraymgray',\n\t'black-cyan': 'blackcyan',\n\t'cyan-black': 'cyanblack',\n\t'black-cream': 'blackcream',\n\t'cream-black': 'creamblack',\n};\n\n/**\n * Parse an AfA PNP 3.0 document into its record: an `access-for-all-pnp` element, or\n * the first one inside an `access-for-all-pnp-record`. A bulk records file holds one\n * profile per candidate, so pass the candidate's record. Returns `null` when the input\n * holds no profile.\n */\nexport function parseAfaPnpXml(xml: string | Element): AfaPnpRecord | null {\n\tconst source = typeof xml === 'string' ? xml : ((xml as Element).outerHTML ?? '');\n\tconst trimmed = source.replace(/<\\?xml[^>]*\\?>/g, '').trim();\n\tif (!trimmed) return null;\n\n\tconst doc = parseHtml(`<root>${trimmed}</root>`, { lowerCaseTagName: false });\n\tconst root = findProfile(doc);\n\tif (!root) return null;\n\n\tconst afaPrefixes = collectAfaPrefixes(root);\n\tconst record: AfaPnpRecord = {};\n\tfor (const child of elementChildren(root)) {\n\t\tconst { prefix, local } = splitName(child.rawTagName);\n\t\tif (prefix && !afaPrefixes.has(prefix)) {\n\t\t\trecord.extensions ??= {};\n\t\t\taddValue(record.extensions, local, elementValue(child));\n\t\t} else if (FEATURE_SETS.has(local)) {\n\t\t\trecord[local] = elementChildren(child).map((feature) => splitName(feature.rawTagName).local);\n\t\t} else {\n\t\t\taddValue(record, local, elementValue(child));\n\t\t}\n\t}\n\treturn record;\n}\n\n/**\n * The part of an AfA record the item player renders. A feature counts when the record\n * names it or one of its activation sets lists it, unless `prohibit-set` lists it.\n * Features with no `PnpProfile` field stay in the record for the host's tools:\n * `fixed-minutes` testing time, `ext:` color themes, and every tool support.\n */\nexport function pnpProfileFromAfa(record: AfaPnpRecord): PnpProfile {\n\tconst prohibited = new Set(record['prohibit-set'] ?? []);\n\tconst listed = new Set([\n\t\t...(record['activate-at-initialization-set'] ?? []),\n\t\t...(record['activate-as-option-set'] ?? []),\n\t]);\n\tconst granted = (feature: string): boolean =>\n\t\t!prohibited.has(feature) && (isPresent(record[feature]) || listed.has(feature));\n\n\tconst display: NonNullable<PnpProfile['display']> = {};\n\tconst theme = granted('text-appearance')\n\t\t? field(record['text-appearance'], 'color-theme')\n\t\t: granted('color-theme')\n\t\t\t? record['color-theme']\n\t\t\t: undefined;\n\tif (typeof theme === 'string' && COLOR_THEMES[theme]) display.colorScheme = COLOR_THEMES[theme];\n\tif (granted('magnification')) {\n\t\tconst magnification = record.magnification;\n\t\tconst zoom =\n\t\t\tfiniteNumber(field(field(magnification, 'all-content'), 'zoom-amount')) ??\n\t\t\tfiniteNumber(field(field(magnification, 'text'), 'zoom-amount'));\n\t\tif (zoom !== undefined && zoom > 0) display.magnification = zoom;\n\t}\n\n\tconst content: NonNullable<PnpProfile['content']> = {};\n\tif (granted('glossary-on-screen')) content.glossaryOnScreen = true;\n\tif (granted('keyword-translation')) {\n\t\tconst languageCode = normalizeLanguageCode(field(record['keyword-translation'], 'language'));\n\t\tif (languageCode) content.keywordTranslation = { active: true, languageCode };\n\t}\n\tif (\n\t\t!prohibited.has(ILLUSTRATED_GLOSSARY_EXTENSION) &&\n\t\tisPresent(record.extensions?.[ILLUSTRATED_GLOSSARY_EXTENSION])\n\t) {\n\t\tcontent.illustratedGlossary = true;\n\t}\n\tfor (const feature of CATALOG_SUPPORT_FEATURES) {\n\t\tif (!granted(feature)) continue;\n\t\tconst languageCode = normalizeLanguageCode(field(record[feature], 'language'));\n\t\tconst preference: CatalogSupportPreference = languageCode ? { active: true, languageCode } : true;\n\t\tcontent.catalogSupports ??= {};\n\t\tcontent.catalogSupports[feature] = preference;\n\t}\n\tif (granted('additional-testing-time')) {\n\t\tconst testingTime = record['additional-testing-time'];\n\t\tconst multiplier = isPresent(field(testingTime, 'unlimited'))\n\t\t\t? Infinity\n\t\t\t: finiteNumber(field(testingTime, 'time-multiplier'));\n\t\tif (multiplier !== undefined && multiplier > 0) content.extendedTime = { active: true, multiplier };\n\t}\n\n\tconst cognitive: NonNullable<PnpProfile['cognitive']> = {};\n\tif (granted('answer-masking')) cognitive.eliminationTool = true;\n\n\tconst profile: PnpProfile = {};\n\tif (Object.keys(display).length > 0) profile.display = display;\n\tif (Object.keys(content).length > 0) profile.content = content;\n\tif (Object.keys(cognitive).length > 0) profile.cognitive = cognitive;\n\treturn profile;\n}\n\n/**\n * Parse an AfA PNP 3.0 document into the `PnpProfile` the item player renders. Returns\n * an empty profile when the input holds none. `parseAfaPnpXml` returns the whole record.\n */\nexport function parsePnpXml(xml: string | Element): PnpProfile {\n\tconst record = parseAfaPnpXml(xml);\n\treturn record ? pnpProfileFromAfa(record) : {};\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction findProfile(parent: NhpElement): NhpElement | null {\n\tfor (const child of elementChildren(parent)) {\n\t\tif (splitName(child.rawTagName).local === 'access-for-all-pnp') return child;\n\t\tconst nested = findProfile(child);\n\t\tif (nested) return nested;\n\t}\n\treturn null;\n}\n\n/** Prefixes bound to an AfA PNP namespace on the profile or its ancestors. */\nfunction collectAfaPrefixes(root: NhpElement): Set<string> {\n\tconst prefixes = new Set<string>();\n\tfor (let el: NhpElement | null = root; el; el = el.parentNode as NhpElement | null) {\n\t\tfor (const [name, value] of Object.entries(el.rawAttributes ?? {})) {\n\t\t\tif (name.startsWith('xmlns:') && value.includes('imsafa3p0pnp')) prefixes.add(name.slice(6));\n\t\t}\n\t}\n\treturn prefixes;\n}\n\nfunction elementChildren(parent: NhpElement): NhpElement[] {\n\treturn parent.childNodes.filter((child): child is NhpElement => child.nodeType === 1);\n}\n\nfunction splitName(name: string | undefined): { prefix?: string; local: string } {\n\tconst raw = name ?? '';\n\tconst colon = raw.indexOf(':');\n\treturn colon < 0 ? { local: raw } : { prefix: raw.slice(0, colon), local: raw.slice(colon + 1) };\n}\n\nfunction elementValue(el: NhpElement): unknown {\n\tconst value: Record<string, unknown> = {};\n\tfor (const [name, raw] of Object.entries(el.rawAttributes ?? {})) {\n\t\tif (name === 'xmlns' || name.startsWith('xmlns:') || name.startsWith('xsi:')) continue;\n\t\taddValue(value, name === 'xml:lang' ? 'language' : splitName(name).local, scalar(raw));\n\t}\n\tconst children = elementChildren(el);\n\tfor (const child of children) {\n\t\taddValue(value, splitName(child.rawTagName).local, elementValue(child));\n\t}\n\tif (children.length > 0 || Object.keys(value).length > 0) return value;\n\tconst text = el.text.trim();\n\treturn text ? scalar(text) : {};\n}\n\nfunction addValue(target: Record<string, unknown>, key: string, value: unknown): void {\n\tif (!(key in target)) {\n\t\ttarget[key] = value;\n\t\treturn;\n\t}\n\tconst existing = target[key];\n\ttarget[key] = Array.isArray(existing) ? [...existing, value] : [existing, value];\n}\n\nfunction scalar(raw: string): string | number | boolean {\n\tconst value = raw.trim();\n\tif (value === 'true') return true;\n\tif (value === 'false') return false;\n\tif (/^-?\\d+(?:\\.\\d+)?$/.test(value)) return Number(value);\n\treturn value;\n}\n\nfunction field(value: unknown, key: string): unknown {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value)\n\t\t? (value as Record<string, unknown>)[key]\n\t\t: undefined;\n}\n\nfunction isPresent(value: unknown): boolean {\n\treturn value !== undefined && value !== null && value !== false;\n}\n\nfunction finiteNumber(value: unknown): number | undefined {\n\treturn typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n}\n\nfunction normalizeLanguageCode(value: unknown): string | undefined {\n\tif (typeof value !== 'string') return undefined;\n\tconst languageCode = value.trim();\n\tif (!/^[a-zA-Z]{2,8}(?:-[a-zA-Z0-9]{1,8})*$/.test(languageCode)) return undefined;\n\treturn languageCode;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  /**
2
- * QTI 3.0 §6.2 Personal Needs and Preferences profile.
3
- * All fields are optional; absent means "use platform default".
2
+ * The candidate needs the item player renders, from a per-candidate AfA PNP 3.0
3
+ * profile (`pnpProfileFromAfa`). All fields are optional; absent means "use platform default".
4
4
  */
5
5
  export interface PnpProfile {
6
6
  display?: {
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/pnp/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * QTI 3.0 §6.2 Personal Needs and Preferences profile.\n * All fields are optional; absent means \"use platform default\".\n */\nexport interface PnpProfile {\n\tdisplay?: {\n\t\t/**\n\t\t * Named color scheme. Maps to the data-qti-colorscheme attribute on the player root.\n\t\t * 'default' or undefined → attribute removed (browser/host default).\n\t\t */\n\t\tcolorScheme?:\n\t\t\t| 'default'\n\t\t\t| 'defaultreverse'\n\t\t\t| 'blackwhite'\n\t\t\t| 'whiteblack'\n\t\t\t| 'blackrose'\n\t\t\t| 'roseblack'\n\t\t\t| 'yellowblue'\n\t\t\t| 'blueyellow'\n\t\t\t| 'mgraydgray'\n\t\t\t| 'dgraymgray'\n\t\t\t| 'blackcyan'\n\t\t\t| 'cyanblack'\n\t\t\t| 'blackcream'\n\t\t\t| 'creamblack'\n\t\t\t| 'whitenav'\n\t\t\t| 'medgray';\n\t\t/**\n\t\t * CSS zoom factor (1.0 = 100%). Deferred — set by browser zoom or host stylesheet.\n\t\t * Stored here for forward-compatibility but not yet applied by the player.\n\t\t */\n\t\tmagnification?: number;\n\t};\n\tcontent?: {\n\t\t/** Show glossary trigger buttons on [data-catalog-idref] terms (G-10). */\n\t\tglossaryOnScreen?: boolean;\n\t\t/** Show keyword-translation trigger buttons using the given language code. */\n\t\tkeywordTranslation?: { active: boolean; languageCode: string };\n\t\t/** Show illustrated glossary supports when catalog entries provide them. */\n\t\tillustratedGlossary?: boolean;\n\t\t/** Enable user-initiated host-routed catalog supports. */\n\t\tcatalogSupports?: CatalogSupportPreferences;\n\t\t/**\n\t\t * Scale assessment time limits. multiplier: 1.5 means 50% extra time.\n\t\t * multiplier: Infinity removes the time limit entirely.\n\t\t */\n\t\textendedTime?: { active: boolean; multiplier: number };\n\t};\n\tcognitive?: {\n\t\t/** Render per-choice elimination toggle buttons in choiceInteraction and orderInteraction. */\n\t\teliminationTool?: boolean;\n\t};\n}\n\nexport interface CatalogSupportPreferences {\n\tttsPronunciation?: CatalogSupportPreference;\n\tsigningDefinition?: CatalogSupportPreference;\n\tbrailleText?: CatalogSupportPreference;\n\taudioDescription?: CatalogSupportPreference;\n\textendedDescription?: CatalogSupportPreference;\n\t/**\n\t * Host-defined catalog usage names. Use QTI/catalog usage strings such as\n\t * \"custom-audio\" rather than DOM event names or implementation-specific APIs.\n\t */\n\t[usage: string]: CatalogSupportPreference | undefined;\n}\n\nexport type CatalogSupportPreference = boolean | CatalogSupportPreferenceOptions;\n\nexport interface CatalogSupportPreferenceOptions {\n\t/** Defaults to true when omitted. */\n\tactive?: boolean;\n\t/** Preferred catalog entry language for this support, such as \"en-US\" or \"es\". */\n\tlanguageCode?: string;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/pnp/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The candidate needs the item player renders, from a per-candidate AfA PNP 3.0\n * profile (`pnpProfileFromAfa`). All fields are optional; absent means \"use platform default\".\n */\nexport interface PnpProfile {\n\tdisplay?: {\n\t\t/**\n\t\t * Named color scheme. Maps to the data-qti-colorscheme attribute on the player root.\n\t\t * 'default' or undefined → attribute removed (browser/host default).\n\t\t */\n\t\tcolorScheme?:\n\t\t\t| 'default'\n\t\t\t| 'defaultreverse'\n\t\t\t| 'blackwhite'\n\t\t\t| 'whiteblack'\n\t\t\t| 'blackrose'\n\t\t\t| 'roseblack'\n\t\t\t| 'yellowblue'\n\t\t\t| 'blueyellow'\n\t\t\t| 'mgraydgray'\n\t\t\t| 'dgraymgray'\n\t\t\t| 'blackcyan'\n\t\t\t| 'cyanblack'\n\t\t\t| 'blackcream'\n\t\t\t| 'creamblack'\n\t\t\t| 'whitenav'\n\t\t\t| 'medgray';\n\t\t/**\n\t\t * CSS zoom factor (1.0 = 100%). Deferred — set by browser zoom or host stylesheet.\n\t\t * Stored here for forward-compatibility but not yet applied by the player.\n\t\t */\n\t\tmagnification?: number;\n\t};\n\tcontent?: {\n\t\t/** Show glossary trigger buttons on [data-catalog-idref] terms (G-10). */\n\t\tglossaryOnScreen?: boolean;\n\t\t/** Show keyword-translation trigger buttons using the given language code. */\n\t\tkeywordTranslation?: { active: boolean; languageCode: string };\n\t\t/** Show illustrated glossary supports when catalog entries provide them. */\n\t\tillustratedGlossary?: boolean;\n\t\t/** Enable user-initiated host-routed catalog supports. */\n\t\tcatalogSupports?: CatalogSupportPreferences;\n\t\t/**\n\t\t * Scale assessment time limits. multiplier: 1.5 means 50% extra time.\n\t\t * multiplier: Infinity removes the time limit entirely.\n\t\t */\n\t\textendedTime?: { active: boolean; multiplier: number };\n\t};\n\tcognitive?: {\n\t\t/** Render per-choice elimination toggle buttons in choiceInteraction and orderInteraction. */\n\t\teliminationTool?: boolean;\n\t};\n}\n\nexport interface CatalogSupportPreferences {\n\tttsPronunciation?: CatalogSupportPreference;\n\tsigningDefinition?: CatalogSupportPreference;\n\tbrailleText?: CatalogSupportPreference;\n\taudioDescription?: CatalogSupportPreference;\n\textendedDescription?: CatalogSupportPreference;\n\t/**\n\t * Host-defined catalog usage names. Use QTI/catalog usage strings such as\n\t * \"custom-audio\" rather than DOM event names or implementation-specific APIs.\n\t */\n\t[usage: string]: CatalogSupportPreference | undefined;\n}\n\nexport type CatalogSupportPreference = boolean | CatalogSupportPreferenceOptions;\n\nexport interface CatalogSupportPreferenceOptions {\n\t/** Defaults to true when omitted. */\n\tactive?: boolean;\n\t/** Preferred catalog entry language for this support, such as \"en-US\" or \"es\". */\n\tlanguageCode?: string;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-qti/item-player",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "description": "Modern QTI player supporting QTI 2.2 and 3.0 - Client-side with optional backend hooks",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -27,14 +27,14 @@
27
27
  ],
28
28
  "license": "MIT",
29
29
  "dependencies": {
30
- "@pie-qti/ims-cp-core": "0.1.25",
31
- "@pie-qti/qti-common": "0.1.25",
32
- "@pie-qti/qti-processing": "0.1.25",
30
+ "@pie-qti/ims-cp-core": "0.1.26",
31
+ "@pie-qti/qti-common": "0.1.26",
32
+ "@pie-qti/qti-processing": "0.1.26",
33
33
  "mathlive": "^0.110.0",
34
- "node-html-parser": "^9.0.1"
34
+ "node-html-parser": "^9.0.4"
35
35
  },
36
36
  "peerDependencies": {
37
- "@pie-qti/i18n": "0.1.25"
37
+ "@pie-qti/i18n": "0.1.26"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@pie-qti/i18n": {
@@ -42,10 +42,10 @@
42
42
  }
43
43
  },
44
44
  "devDependencies": {
45
- "@biomejs/biome": "^2.5.14",
46
- "@pie-qti/i18n": "0.1.25",
45
+ "@biomejs/biome": "^2.5.15",
46
+ "@pie-qti/i18n": "0.1.26",
47
47
  "@sveltejs/vite-plugin-svelte": "^7.3.0",
48
- "@types/node": "^26.6.2",
48
+ "@types/node": "^26.6.4",
49
49
  "svelte": "^5.57.1",
50
50
  "svelte-check": "^4.7.5",
51
51
  "typescript": "^5.9.3",