@pie-qti/qti-common 0.1.19 → 0.1.20

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 CHANGED
@@ -36,7 +36,7 @@ const canonicalName = mapper.toCanonical('qti-choice-interaction');
36
36
  // → "choiceinteraction"
37
37
 
38
38
  const nativeName = mapper.toNative('choiceinteraction');
39
- // → "qti-choice-interaction" (QTI 3.0) or "choiceInteraction" (QTI 2.x)
39
+ // → "qti-choice-interaction" (QTI 3.0) or "choiceinteraction" (QTI 2.x)
40
40
  ```
41
41
 
42
42
  ### Element Name Mapping
@@ -44,12 +44,12 @@ const nativeName = mapper.toNative('choiceinteraction');
44
44
  The package provides mappers for both QTI versions:
45
45
 
46
46
  ```typescript
47
- import { Qti2ElementNameMapper, Qti3ElementNameMapper } from '@pie-qti/qti-common';
47
+ import { Qti2xElementNameMapper, Qti3ElementNameMapper } from '@pie-qti/qti-common';
48
48
 
49
49
  // QTI 2.x (camelCase)
50
- const qti2Mapper = new Qti2ElementNameMapper();
50
+ const qti2Mapper = new Qti2xElementNameMapper();
51
51
  qti2Mapper.toCanonical('choiceInteraction'); // → "choiceinteraction"
52
- qti2Mapper.toNative('choiceinteraction'); // → "choiceInteraction"
52
+ qti2Mapper.toNative('choiceinteraction'); // → "choiceinteraction"
53
53
 
54
54
  // QTI 3.0 (kebab-case with qti- prefix)
55
55
  const qti3Mapper = new Qti3ElementNameMapper();
@@ -57,6 +57,10 @@ qti3Mapper.toCanonical('qti-choice-interaction'); // → "choiceinteraction"
57
57
  qti3Mapper.toNative('choiceinteraction'); // → "qti-choice-interaction"
58
58
  ```
59
59
 
60
+ `Qti2xElementNameMapper.toNative()` returns the lowercase canonical spelling because the parser's
61
+ QTI 2.x matching is case-insensitive; it cannot reconstruct the original camelCase from a lowercase
62
+ name. Preserve the source spelling separately when exact XML serialization matters.
63
+
60
64
  ### Smart Attribute Accessors
61
65
 
62
66
  The package provides attribute accessors that work with both naming conventions:
@@ -114,7 +118,7 @@ getBooleanAttribute(element, 'shuffle'); // Returns boolean
114
118
  │ action> │
115
119
  └────────┬───────┘
116
120
  │
117
- ├──► Qti2ElementNameMapper
121
+ ├──► Qti2xElementNameMapper
118
122
  │ toCanonical('choiceInteraction')
119
123
  │ ↓
120
124
  │ "choiceinteraction"
@@ -171,14 +175,14 @@ The package auto-detects QTI version from:
171
175
 
172
176
  ### Parser Factory
173
177
 
174
- #### `createQtiParser(xml: string, options?: { version?: string })`
178
+ #### `createQtiParser(xml: string, options?: CreateParserOptions)`
175
179
 
176
180
  Creates appropriate parser configuration for the given QTI XML.
177
181
 
178
- **Returns**: `{ mapper: ElementNameMapper, version: string }`
182
+ **Returns**: `{ mapper: ElementNameMapper, attributeMapper: AttributeNameMapper, version: QtiVersion }`
179
183
 
180
184
  ```typescript
181
- const { mapper, version } = createQtiParser(xml);
185
+ const { mapper, attributeMapper, version } = createQtiParser(xml);
182
186
  ```
183
187
 
184
188
  #### `isQti3(xml: string): boolean`
@@ -197,6 +201,9 @@ if (isQti3(xml)) {
197
201
 
198
202
  ```typescript
199
203
  interface ElementNameMapper {
204
+ /** QTI version represented by this mapper */
205
+ readonly version: string;
206
+
200
207
  /** Convert version-specific name to canonical form */
201
208
  toCanonical(elementName: string): string;
202
209
 
@@ -208,14 +215,14 @@ interface ElementNameMapper {
208
215
  }
209
216
  ```
210
217
 
211
- #### `Qti2ElementNameMapper`
218
+ #### `Qti2xElementNameMapper`
212
219
 
213
220
  Handles QTI 2.x camelCase element names.
214
221
 
215
222
  ```typescript
216
- const mapper = new Qti2ElementNameMapper();
223
+ const mapper = new Qti2xElementNameMapper();
217
224
  mapper.toCanonical('choiceInteraction'); // → "choiceinteraction"
218
- mapper.toNative('choiceinteraction'); // → "choiceInteraction"
225
+ mapper.toNative('choiceinteraction'); // → "choiceinteraction"
219
226
  ```
220
227
 
221
228
  #### `Qti3ElementNameMapper`
@@ -260,17 +267,21 @@ const shuffle = getBooleanAttribute(element, 'shuffle', false);
260
267
  ### Item Player Integration
261
268
 
262
269
  ```typescript
263
- import { Player } from '@pie-qti/item-player';
270
+ import { createAssessmentItemDefinition } from '@pie-qti/item-player';
264
271
  import { createQtiParser } from '@pie-qti/qti-common';
265
272
 
266
273
  const xml = `...(QTI 2.x or 3.0)...`;
267
- const { mapper, version } = createQtiParser(xml);
274
+ const { mapper, attributeMapper, version } = createQtiParser(xml);
268
275
 
269
- const player = new Player(xml, {
270
- elementNameMapper: mapper // Optional - auto-detected if not provided
276
+ const definition = createAssessmentItemDefinition({
277
+ itemXml: xml,
278
+ elementNameMapper: mapper,
279
+ attributeNameMapper: attributeMapper
271
280
  });
281
+ const session = definition.openSession();
272
282
 
273
283
  console.log(`Playing ${version} content`);
284
+ session.dispose();
274
285
  ```
275
286
 
276
287
  ### Transform Integration
@@ -317,7 +328,8 @@ const elements = doc.getElementsByTagName(tagName);
317
328
 
318
329
  ```typescript
319
330
  // No changes needed! Extraction layer already uses mappers internally
320
- const player = new Player(xml); // Works with both QTI 2.x and 3.0
331
+ const definition = createAssessmentItemDefinition({ itemXml: xml });
332
+ const session = definition.openSession(); // Works with both QTI 2.x and 3.0
321
333
  ```
322
334
 
323
335
  ### Attribute Handling Migration
@@ -16,8 +16,11 @@ export interface SvelteMountController<TProps, TInstance> {
16
16
  /**
17
17
  * Owns Svelte custom-element mount policy in one place.
18
18
  *
19
- * Svelte 5 runes components do not expose `$set`, so updates fall back to one
20
- * microtask-scheduled remount. Coalescing here prevents synchronous remount
21
- * loops in custom element setters and attribute callbacks.
19
+ * Svelte 5 runes components do not support `$set`, so updates fall back to one
20
+ * microtask-scheduled remount. Development builds may still expose a `$set`
21
+ * compatibility shim that throws `component_api_changed`; treat that shim as
22
+ * unsupported while preserving genuine Svelte 4-compatible instances.
23
+ * Coalescing here prevents synchronous remount loops in custom element setters
24
+ * and attribute callbacks.
22
25
  */
23
26
  export declare function createSvelteMountController<TProps, TInstance>({ host, mount, unmount, createContainer, }: SvelteMountControllerOptions<TProps, TInstance>): SvelteMountController<TProps, TInstance>;
@@ -1,9 +1,12 @@
1
1
  /**
2
2
  * Owns Svelte custom-element mount policy in one place.
3
3
  *
4
- * Svelte 5 runes components do not expose `$set`, so updates fall back to one
5
- * microtask-scheduled remount. Coalescing here prevents synchronous remount
6
- * loops in custom element setters and attribute callbacks.
4
+ * Svelte 5 runes components do not support `$set`, so updates fall back to one
5
+ * microtask-scheduled remount. Development builds may still expose a `$set`
6
+ * compatibility shim that throws `component_api_changed`; treat that shim as
7
+ * unsupported while preserving genuine Svelte 4-compatible instances.
8
+ * Coalescing here prevents synchronous remount loops in custom element setters
9
+ * and attribute callbacks.
7
10
  */
8
11
  export function createSvelteMountController({ host, mount, unmount, createContainer = defaultContainer, }) {
9
12
  let container = null;
@@ -59,8 +62,14 @@ export function createSvelteMountController({ host, mount, unmount, createContai
59
62
  return;
60
63
  const set = instance.$set;
61
64
  if (typeof set === 'function') {
62
- set.call(instance, props);
63
- return;
65
+ try {
66
+ set.call(instance, props);
67
+ return;
68
+ }
69
+ catch (error) {
70
+ if (!isSvelteComponentApiChanged(error))
71
+ throw error;
72
+ }
64
73
  }
65
74
  scheduleRemount();
66
75
  }
@@ -84,6 +93,9 @@ export function createSvelteMountController({ host, mount, unmount, createContai
84
93
  teardown,
85
94
  };
86
95
  }
96
+ function isSvelteComponentApiChanged(error) {
97
+ return error instanceof Error && error.message.includes('https://svelte.dev/e/component_api_changed');
98
+ }
87
99
  function defaultContainer() {
88
100
  const container = document.createElement('div');
89
101
  container.style.display = 'contents';
@@ -1 +1 @@
1
- {"version":3,"file":"svelteMountController.js","sourceRoot":"","sources":["../../src/dom/svelteMountController.ts"],"names":[],"mappings":"AAmBA;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CAAoB,EAC9D,IAAI,EACJ,KAAK,EACL,OAAO,EACP,eAAe,GAAG,gBAAgB,GACe;IACjD,IAAI,SAAS,GAAuB,IAAI,CAAC;IACzC,IAAI,QAAQ,GAAqB,IAAI,CAAC;IACtC,IAAI,cAAc,GAAG,KAAK,CAAC;IAC3B,IAAI,WAAW,GAAkB,IAAI,CAAC;IAEtC,SAAS,eAAe;QACvB,IAAI,CAAC,SAAS,EAAE,CAAC;YAChB,SAAS,GAAG,eAAe,EAAE,CAAC;YAC9B,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,SAAS,UAAU,CAAC,KAAa;QAChC,WAAW,GAAG,KAAK,CAAC;QACpB,QAAQ,GAAG,KAAK,CAAC,eAAe,EAAE,EAAE,KAAK,CAAC,CAAC;QAC3C,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED,SAAS,eAAe;QACvB,IAAI,cAAc;YAAE,OAAO;QAC3B,cAAc,GAAG,IAAI,CAAC;QACtB,cAAc,CAAC,GAAG,EAAE;YACnB,cAAc,GAAG,KAAK,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,SAAS,IAAI,WAAW,KAAK,IAAI;gBAAE,OAAO;YACpE,gBAAgB,EAAE,CAAC;YACnB,UAAU,CAAC,WAAW,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,SAAS,gBAAgB;QACxB,IAAI,CAAC,QAAQ;YAAE,OAAO;QACtB,IAAI,CAAC;YACJ,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACR,8DAA8D;QAC/D,CAAC;QACD,QAAQ,GAAG,IAAI,CAAC;IACjB,CAAC;IAED,SAAS,aAAa,CAAC,KAAa;QACnC,WAAW,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,CAAC;QACd,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED,SAAS,MAAM,CAAC,KAAa;QAC5B,WAAW,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,QAAQ;YAAE,OAAO;QAEtB,MAAM,GAAG,GAAI,QAA2C,CAAC,IAAI,CAAC;QAC9D,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;YAC/B,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC1B,OAAO;QACR,CAAC;QAED,eAAe,EAAE,CAAC;IACnB,CAAC;IAED,SAAS,QAAQ,CAAC,UAAyC,EAAE;QAC5D,cAAc,GAAG,KAAK,CAAC;QACvB,gBAAgB,EAAE,CAAC;QACnB,IAAI,OAAO,CAAC,eAAe,IAAI,IAAI,EAAE,CAAC;YACrC,SAAS,EAAE,MAAM,EAAE,CAAC;YACpB,SAAS,GAAG,IAAI,CAAC;QAClB,CAAC;IACF,CAAC;IAED,OAAO;QACN,IAAI,QAAQ;YACX,OAAO,QAAQ,CAAC;QACjB,CAAC;QACD,IAAI,OAAO;YACV,OAAO,QAAQ,KAAK,IAAI,CAAC;QAC1B,CAAC;QACD,aAAa;QACb,MAAM;QACN,QAAQ;KACR,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB;IACxB,MAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAChD,SAAS,CAAC,KAAK,CAAC,OAAO,GAAG,UAAU,CAAC;IACrC,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["export interface SvelteMountControllerOptions<TProps, TInstance> {\n\thost: HTMLElement;\n\tmount: (target: HTMLElement, props: TProps) => TInstance;\n\tunmount: (instance: TInstance) => void | Promise<void>;\n\tcreateContainer?: () => HTMLElement;\n}\n\nexport interface SvelteMountController<TProps, TInstance> {\n\treadonly instance: TInstance | null;\n\treadonly mounted: boolean;\n\tmountOrUpdate(props: TProps): TInstance | null;\n\tupdate(props: TProps): void;\n\tteardown(options?: { removeContainer?: boolean }): void;\n}\n\ntype SettableSvelteInstance<TProps> = {\n\t$set?: (props: TProps) => void;\n};\n\n/**\n * Owns Svelte custom-element mount policy in one place.\n *\n * Svelte 5 runes components do not expose `$set`, so updates fall back to one\n * microtask-scheduled remount. Coalescing here prevents synchronous remount\n * loops in custom element setters and attribute callbacks.\n */\nexport function createSvelteMountController<TProps, TInstance>({\n\thost,\n\tmount,\n\tunmount,\n\tcreateContainer = defaultContainer,\n}: SvelteMountControllerOptions<TProps, TInstance>): SvelteMountController<TProps, TInstance> {\n\tlet container: HTMLElement | null = null;\n\tlet instance: TInstance | null = null;\n\tlet pendingRemount = false;\n\tlet latestProps: TProps | null = null;\n\n\tfunction ensureContainer() {\n\t\tif (!container) {\n\t\t\tcontainer = createContainer();\n\t\t\thost.appendChild(container);\n\t\t}\n\t\treturn container;\n\t}\n\n\tfunction mountFresh(props: TProps) {\n\t\tlatestProps = props;\n\t\tinstance = mount(ensureContainer(), props);\n\t\treturn instance;\n\t}\n\n\tfunction scheduleRemount() {\n\t\tif (pendingRemount) return;\n\t\tpendingRemount = true;\n\t\tqueueMicrotask(() => {\n\t\t\tpendingRemount = false;\n\t\t\tif (!host.isConnected || !container || latestProps === null) return;\n\t\t\tteardownInstance();\n\t\t\tmountFresh(latestProps);\n\t\t});\n\t}\n\n\tfunction teardownInstance() {\n\t\tif (!instance) return;\n\t\ttry {\n\t\t\tvoid unmount(instance);\n\t\t} catch {\n\t\t\t// Unmount should not make custom-element disconnection throw.\n\t\t}\n\t\tinstance = null;\n\t}\n\n\tfunction mountOrUpdate(props: TProps) {\n\t\tlatestProps = props;\n\t\tif (!instance) {\n\t\t\treturn mountFresh(props);\n\t\t}\n\t\tupdate(props);\n\t\treturn instance;\n\t}\n\n\tfunction update(props: TProps) {\n\t\tlatestProps = props;\n\t\tif (!instance) return;\n\n\t\tconst set = (instance as SettableSvelteInstance<TProps>).$set;\n\t\tif (typeof set === 'function') {\n\t\t\tset.call(instance, props);\n\t\t\treturn;\n\t\t}\n\n\t\tscheduleRemount();\n\t}\n\n\tfunction teardown(options: { removeContainer?: boolean } = {}) {\n\t\tpendingRemount = false;\n\t\tteardownInstance();\n\t\tif (options.removeContainer ?? true) {\n\t\t\tcontainer?.remove();\n\t\t\tcontainer = null;\n\t\t}\n\t}\n\n\treturn {\n\t\tget instance() {\n\t\t\treturn instance;\n\t\t},\n\t\tget mounted() {\n\t\t\treturn instance !== null;\n\t\t},\n\t\tmountOrUpdate,\n\t\tupdate,\n\t\tteardown,\n\t};\n}\n\nfunction defaultContainer() {\n\tconst container = document.createElement('div');\n\tcontainer.style.display = 'contents';\n\treturn container;\n}\n"]}
1
+ {"version":3,"file":"svelteMountController.js","sourceRoot":"","sources":["../../src/dom/svelteMountController.ts"],"names":[],"mappings":"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","sourcesContent":["export interface SvelteMountControllerOptions<TProps, TInstance> {\n\thost: HTMLElement;\n\tmount: (target: HTMLElement, props: TProps) => TInstance;\n\tunmount: (instance: TInstance) => void | Promise<void>;\n\tcreateContainer?: () => HTMLElement;\n}\n\nexport interface SvelteMountController<TProps, TInstance> {\n\treadonly instance: TInstance | null;\n\treadonly mounted: boolean;\n\tmountOrUpdate(props: TProps): TInstance | null;\n\tupdate(props: TProps): void;\n\tteardown(options?: { removeContainer?: boolean }): void;\n}\n\ntype SettableSvelteInstance<TProps> = {\n\t$set?: (props: TProps) => void;\n};\n\n/**\n * Owns Svelte custom-element mount policy in one place.\n *\n * Svelte 5 runes components do not support `$set`, so updates fall back to one\n * microtask-scheduled remount. Development builds may still expose a `$set`\n * compatibility shim that throws `component_api_changed`; treat that shim as\n * unsupported while preserving genuine Svelte 4-compatible instances.\n * Coalescing here prevents synchronous remount loops in custom element setters\n * and attribute callbacks.\n */\nexport function createSvelteMountController<TProps, TInstance>({\n\thost,\n\tmount,\n\tunmount,\n\tcreateContainer = defaultContainer,\n}: SvelteMountControllerOptions<TProps, TInstance>): SvelteMountController<TProps, TInstance> {\n\tlet container: HTMLElement | null = null;\n\tlet instance: TInstance | null = null;\n\tlet pendingRemount = false;\n\tlet latestProps: TProps | null = null;\n\n\tfunction ensureContainer() {\n\t\tif (!container) {\n\t\t\tcontainer = createContainer();\n\t\t\thost.appendChild(container);\n\t\t}\n\t\treturn container;\n\t}\n\n\tfunction mountFresh(props: TProps) {\n\t\tlatestProps = props;\n\t\tinstance = mount(ensureContainer(), props);\n\t\treturn instance;\n\t}\n\n\tfunction scheduleRemount() {\n\t\tif (pendingRemount) return;\n\t\tpendingRemount = true;\n\t\tqueueMicrotask(() => {\n\t\t\tpendingRemount = false;\n\t\t\tif (!host.isConnected || !container || latestProps === null) return;\n\t\t\tteardownInstance();\n\t\t\tmountFresh(latestProps);\n\t\t});\n\t}\n\n\tfunction teardownInstance() {\n\t\tif (!instance) return;\n\t\ttry {\n\t\t\tvoid unmount(instance);\n\t\t} catch {\n\t\t\t// Unmount should not make custom-element disconnection throw.\n\t\t}\n\t\tinstance = null;\n\t}\n\n\tfunction mountOrUpdate(props: TProps) {\n\t\tlatestProps = props;\n\t\tif (!instance) {\n\t\t\treturn mountFresh(props);\n\t\t}\n\t\tupdate(props);\n\t\treturn instance;\n\t}\n\n\tfunction update(props: TProps) {\n\t\tlatestProps = props;\n\t\tif (!instance) return;\n\n\t\tconst set = (instance as SettableSvelteInstance<TProps>).$set;\n\t\tif (typeof set === 'function') {\n\t\t\ttry {\n\t\t\t\tset.call(instance, props);\n\t\t\t\treturn;\n\t\t\t} catch (error) {\n\t\t\t\tif (!isSvelteComponentApiChanged(error)) throw error;\n\t\t\t}\n\t\t}\n\n\t\tscheduleRemount();\n\t}\n\n\tfunction teardown(options: { removeContainer?: boolean } = {}) {\n\t\tpendingRemount = false;\n\t\tteardownInstance();\n\t\tif (options.removeContainer ?? true) {\n\t\t\tcontainer?.remove();\n\t\t\tcontainer = null;\n\t\t}\n\t}\n\n\treturn {\n\t\tget instance() {\n\t\t\treturn instance;\n\t\t},\n\t\tget mounted() {\n\t\t\treturn instance !== null;\n\t\t},\n\t\tmountOrUpdate,\n\t\tupdate,\n\t\tteardown,\n\t};\n}\n\nfunction isSvelteComponentApiChanged(error: unknown): error is Error {\n\treturn error instanceof Error && error.message.includes('https://svelte.dev/e/component_api_changed');\n}\n\nfunction defaultContainer() {\n\tconst container = document.createElement('div');\n\tcontainer.style.display = 'contents';\n\treturn container;\n}\n"]}
@@ -53,19 +53,23 @@ export interface CreateParserOptions {
53
53
  *
54
54
  * @param xml - QTI XML content as string
55
55
  * @param options - Optional configuration
56
- * @returns Parser result with version and mapper
56
+ * @returns Parser result with version plus element and attribute mappers
57
57
  *
58
58
  * @example
59
59
  * ```typescript
60
60
  * // Auto-detect version and create appropriate parser
61
- * const { version, mapper } = createQtiParser(xml);
61
+ * const { version, mapper, attributeMapper } = createQtiParser(xml);
62
62
  * console.log(`Detected QTI ${version}`);
63
63
  *
64
64
  * // Use with qti-processing
65
65
  * const program = buildResponseProcessingAst(responseProcessing, { elementNameMapper: mapper });
66
66
  *
67
67
  * // Use with item-player
68
- * const player = new Player(xml, { elementNameMapper: mapper });
68
+ * const definition = createAssessmentItemDefinition({
69
+ * itemXml: xml,
70
+ * elementNameMapper: mapper,
71
+ * attributeNameMapper: attributeMapper
72
+ * });
69
73
  * ```
70
74
  *
71
75
  * @example
@@ -18,19 +18,23 @@ import { Qti3AttributeNameMapper } from './element-mapper/Qti3AttributeNameMappe
18
18
  *
19
19
  * @param xml - QTI XML content as string
20
20
  * @param options - Optional configuration
21
- * @returns Parser result with version and mapper
21
+ * @returns Parser result with version plus element and attribute mappers
22
22
  *
23
23
  * @example
24
24
  * ```typescript
25
25
  * // Auto-detect version and create appropriate parser
26
- * const { version, mapper } = createQtiParser(xml);
26
+ * const { version, mapper, attributeMapper } = createQtiParser(xml);
27
27
  * console.log(`Detected QTI ${version}`);
28
28
  *
29
29
  * // Use with qti-processing
30
30
  * const program = buildResponseProcessingAst(responseProcessing, { elementNameMapper: mapper });
31
31
  *
32
32
  * // Use with item-player
33
- * const player = new Player(xml, { elementNameMapper: mapper });
33
+ * const definition = createAssessmentItemDefinition({
34
+ * itemXml: xml,
35
+ * elementNameMapper: mapper,
36
+ * attributeNameMapper: attributeMapper
37
+ * });
34
38
  * ```
35
39
  *
36
40
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"parser-factory.js","sourceRoot":"","sources":["../src/parser-factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAmB,MAAM,yCAAyC,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAElF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AA8CtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,OAA6B;IACzE,kCAAkC;IAClC,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAE1D,oEAAoE;IACpE,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAClE,MAAM,eAAe,GAAG,OAAO,EAAE,eAAe,IAAI,+BAA+B,CAAC,OAAO,CAAC,CAAC;IAE7F,OAAO;QACN,OAAO;QACP,MAAM;QACN,eAAe;KACf,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAmB;IACzD,QAAQ,OAAO,EAAE,CAAC;QACjB,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK;YACT,OAAO,IAAI,sBAAsB,EAAE,CAAC;QAErC,KAAK,KAAK;YACT,OAAO,IAAI,qBAAqB,EAAE,CAAC;QAEpC,KAAK,SAAS,CAAC;QACf;YACC,iDAAiD;YACjD,qCAAqC;YACrC,OAAO,IAAI,sBAAsB,EAAE,CAAC;IACtC,CAAC;AACF,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,+BAA+B,CAAC,OAAmB;IAClE,QAAQ,OAAO,EAAE,CAAC;QACjB,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK;YACT,OAAO,IAAI,wBAAwB,EAAE,CAAC;QAEvC,KAAK,KAAK;YACT,OAAO,IAAI,uBAAuB,EAAE,CAAC;QAEtC,KAAK,SAAS,CAAC;QACf;YACC,iDAAiD;YACjD,OAAO,IAAI,wBAAwB,EAAE,CAAC;IACxC,CAAC;AACF,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,MAAM,CAAC,GAAW;IACjC,OAAO,gBAAgB,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,MAAM,CAAC,GAAW;IACjC,MAAM,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,OAAO,KAAK,KAAK,IAAI,OAAO,KAAK,KAAK,IAAI,OAAO,KAAK,KAAK,CAAC;AACpE,CAAC","sourcesContent":["/**\n * Parser factory for creating version-appropriate QTI parsers.\n *\n * This module provides a unified entry point for detecting QTI version\n * and creating appropriate element name mappers.\n */\n\nimport { detectQtiVersion, type QtiVersion } from './version-detection/detectQtiVersion.js';\nimport { Qti2xElementNameMapper } from './element-mapper/Qti2xElementNameMapper.js';\nimport { Qti3ElementNameMapper } from './element-mapper/Qti3ElementNameMapper.js';\nimport type { ElementNameMapper } from './element-mapper/ElementNameMapper.js';\nimport { Qti2xAttributeNameMapper } from './element-mapper/Qti2xAttributeNameMapper.js';\nimport { Qti3AttributeNameMapper } from './element-mapper/Qti3AttributeNameMapper.js';\nimport type { AttributeNameMapper } from './element-mapper/AttributeNameMapper.js';\n\n/**\n * Result of creating a QTI parser.\n */\nexport interface QtiParserResult {\n\t/**\n\t * Detected or specified QTI version\n\t */\n\tversion: QtiVersion;\n\n\t/**\n\t * Element name mapper appropriate for the detected version\n\t */\n\tmapper: ElementNameMapper;\n\n\t/**\n\t * Attribute name mapper appropriate for the detected version\n\t */\n\tattributeMapper: AttributeNameMapper;\n}\n\n/**\n * Options for creating a QTI parser.\n */\nexport interface CreateParserOptions {\n\t/**\n\t * Override automatic version detection.\n\t * If not provided, version will be detected from XML content.\n\t */\n\tversion?: QtiVersion;\n\n\t/**\n\t * Custom element name mapper to use.\n\t * If provided, overrides automatic mapper selection.\n\t */\n\tmapper?: ElementNameMapper;\n\n\t/**\n\t * Custom attribute name mapper to use.\n\t * If provided, overrides automatic mapper selection.\n\t */\n\tattributeMapper?: AttributeNameMapper;\n}\n\n/**\n * Create a QTI parser with appropriate element name mapper for the given XML.\n *\n * This function automatically detects the QTI version and returns the appropriate\n * element name mapper. It can be used as the primary entry point for parsing\n * any QTI content.\n *\n * @param xml - QTI XML content as string\n * @param options - Optional configuration\n * @returns Parser result with version and mapper\n *\n * @example\n * ```typescript\n * // Auto-detect version and create appropriate parser\n * const { version, mapper } = createQtiParser(xml);\n * console.log(`Detected QTI ${version}`);\n *\n * // Use with qti-processing\n * const program = buildResponseProcessingAst(responseProcessing, { elementNameMapper: mapper });\n *\n * // Use with item-player\n * const player = new Player(xml, { elementNameMapper: mapper });\n * ```\n *\n * @example\n * ```typescript\n * // Force specific version\n * const { mapper } = createQtiParser(xml, { version: '3.0' });\n * ```\n */\nexport function createQtiParser(xml: string, options?: CreateParserOptions): QtiParserResult {\n\t// Detect or use specified version\n\tconst version = options?.version ?? detectQtiVersion(xml);\n\n\t// Use custom mappers if provided, otherwise create appropriate ones\n\tconst mapper = options?.mapper ?? createMapperForVersion(version);\n\tconst attributeMapper = options?.attributeMapper ?? createAttributeMapperForVersion(version);\n\n\treturn {\n\t\tversion,\n\t\tmapper,\n\t\tattributeMapper,\n\t};\n}\n\n/**\n * Create element name mapper for a specific QTI version.\n *\n * @param version - QTI version\n * @returns Element name mapper for the version\n *\n * @example\n * ```typescript\n * const qti2Mapper = createMapperForVersion('2.2');\n * const qti3Mapper = createMapperForVersion('3.0');\n * ```\n */\nexport function createMapperForVersion(version: QtiVersion): ElementNameMapper {\n\tswitch (version) {\n\t\tcase '2.0':\n\t\tcase '2.1':\n\t\tcase '2.2':\n\t\t\treturn new Qti2xElementNameMapper();\n\n\t\tcase '3.0':\n\t\t\treturn new Qti3ElementNameMapper();\n\n\t\tcase 'unknown':\n\t\tdefault:\n\t\t\t// Default to QTI 2.x mapper for unknown versions\n\t\t\t// (most existing content is QTI 2.x)\n\t\t\treturn new Qti2xElementNameMapper();\n\t}\n}\n\n/**\n * Create attribute name mapper for a specific QTI version.\n *\n * @param version - QTI version\n * @returns Attribute name mapper for the version\n *\n * @example\n * ```typescript\n * const qti2AttrMapper = createAttributeMapperForVersion('2.2');\n * const qti3AttrMapper = createAttributeMapperForVersion('3.0');\n * ```\n */\nexport function createAttributeMapperForVersion(version: QtiVersion): AttributeNameMapper {\n\tswitch (version) {\n\t\tcase '2.0':\n\t\tcase '2.1':\n\t\tcase '2.2':\n\t\t\treturn new Qti2xAttributeNameMapper();\n\n\t\tcase '3.0':\n\t\t\treturn new Qti3AttributeNameMapper();\n\n\t\tcase 'unknown':\n\t\tdefault:\n\t\t\t// Default to QTI 2.x mapper for unknown versions\n\t\t\treturn new Qti2xAttributeNameMapper();\n\t}\n}\n\n/**\n * Check if XML content is QTI 3.0.\n *\n * Convenience function for quickly checking if content uses QTI 3.0.\n *\n * @param xml - QTI XML content\n * @returns true if QTI 3.0, false otherwise\n *\n * @example\n * ```typescript\n * if (isQti3(xml)) {\n * console.log('This is QTI 3.0 content');\n * }\n * ```\n */\nexport function isQti3(xml: string): boolean {\n\treturn detectQtiVersion(xml) === '3.0';\n}\n\n/**\n * Check if XML content is QTI 2.x (2.0, 2.1, or 2.2).\n *\n * @param xml - QTI XML content\n * @returns true if QTI 2.x, false otherwise\n *\n * @example\n * ```typescript\n * if (isQti2(xml)) {\n * console.log('This is QTI 2.x content');\n * }\n * ```\n */\nexport function isQti2(xml: string): boolean {\n\tconst version = detectQtiVersion(xml);\n\treturn version === '2.0' || version === '2.1' || version === '2.2';\n}\n"]}
1
+ {"version":3,"file":"parser-factory.js","sourceRoot":"","sources":["../src/parser-factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAmB,MAAM,yCAAyC,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAElF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AA8CtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,OAA6B;IACzE,kCAAkC;IAClC,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAE1D,oEAAoE;IACpE,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAClE,MAAM,eAAe,GAAG,OAAO,EAAE,eAAe,IAAI,+BAA+B,CAAC,OAAO,CAAC,CAAC;IAE7F,OAAO;QACN,OAAO;QACP,MAAM;QACN,eAAe;KACf,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAmB;IACzD,QAAQ,OAAO,EAAE,CAAC;QACjB,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK;YACT,OAAO,IAAI,sBAAsB,EAAE,CAAC;QAErC,KAAK,KAAK;YACT,OAAO,IAAI,qBAAqB,EAAE,CAAC;QAEpC,KAAK,SAAS,CAAC;QACf;YACC,iDAAiD;YACjD,qCAAqC;YACrC,OAAO,IAAI,sBAAsB,EAAE,CAAC;IACtC,CAAC;AACF,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,+BAA+B,CAAC,OAAmB;IAClE,QAAQ,OAAO,EAAE,CAAC;QACjB,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK;YACT,OAAO,IAAI,wBAAwB,EAAE,CAAC;QAEvC,KAAK,KAAK;YACT,OAAO,IAAI,uBAAuB,EAAE,CAAC;QAEtC,KAAK,SAAS,CAAC;QACf;YACC,iDAAiD;YACjD,OAAO,IAAI,wBAAwB,EAAE,CAAC;IACxC,CAAC;AACF,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,MAAM,CAAC,GAAW;IACjC,OAAO,gBAAgB,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,MAAM,CAAC,GAAW;IACjC,MAAM,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,OAAO,KAAK,KAAK,IAAI,OAAO,KAAK,KAAK,IAAI,OAAO,KAAK,KAAK,CAAC;AACpE,CAAC","sourcesContent":["/**\n * Parser factory for creating version-appropriate QTI parsers.\n *\n * This module provides a unified entry point for detecting QTI version\n * and creating appropriate element name mappers.\n */\n\nimport { detectQtiVersion, type QtiVersion } from './version-detection/detectQtiVersion.js';\nimport { Qti2xElementNameMapper } from './element-mapper/Qti2xElementNameMapper.js';\nimport { Qti3ElementNameMapper } from './element-mapper/Qti3ElementNameMapper.js';\nimport type { ElementNameMapper } from './element-mapper/ElementNameMapper.js';\nimport { Qti2xAttributeNameMapper } from './element-mapper/Qti2xAttributeNameMapper.js';\nimport { Qti3AttributeNameMapper } from './element-mapper/Qti3AttributeNameMapper.js';\nimport type { AttributeNameMapper } from './element-mapper/AttributeNameMapper.js';\n\n/**\n * Result of creating a QTI parser.\n */\nexport interface QtiParserResult {\n\t/**\n\t * Detected or specified QTI version\n\t */\n\tversion: QtiVersion;\n\n\t/**\n\t * Element name mapper appropriate for the detected version\n\t */\n\tmapper: ElementNameMapper;\n\n\t/**\n\t * Attribute name mapper appropriate for the detected version\n\t */\n\tattributeMapper: AttributeNameMapper;\n}\n\n/**\n * Options for creating a QTI parser.\n */\nexport interface CreateParserOptions {\n\t/**\n\t * Override automatic version detection.\n\t * If not provided, version will be detected from XML content.\n\t */\n\tversion?: QtiVersion;\n\n\t/**\n\t * Custom element name mapper to use.\n\t * If provided, overrides automatic mapper selection.\n\t */\n\tmapper?: ElementNameMapper;\n\n\t/**\n\t * Custom attribute name mapper to use.\n\t * If provided, overrides automatic mapper selection.\n\t */\n\tattributeMapper?: AttributeNameMapper;\n}\n\n/**\n * Create a QTI parser with appropriate element name mapper for the given XML.\n *\n * This function automatically detects the QTI version and returns the appropriate\n * element name mapper. It can be used as the primary entry point for parsing\n * any QTI content.\n *\n * @param xml - QTI XML content as string\n * @param options - Optional configuration\n * @returns Parser result with version plus element and attribute mappers\n *\n * @example\n * ```typescript\n * // Auto-detect version and create appropriate parser\n * const { version, mapper, attributeMapper } = createQtiParser(xml);\n * console.log(`Detected QTI ${version}`);\n *\n * // Use with qti-processing\n * const program = buildResponseProcessingAst(responseProcessing, { elementNameMapper: mapper });\n *\n * // Use with item-player\n * const definition = createAssessmentItemDefinition({\n * itemXml: xml,\n * elementNameMapper: mapper,\n * attributeNameMapper: attributeMapper\n * });\n * ```\n *\n * @example\n * ```typescript\n * // Force specific version\n * const { mapper } = createQtiParser(xml, { version: '3.0' });\n * ```\n */\nexport function createQtiParser(xml: string, options?: CreateParserOptions): QtiParserResult {\n\t// Detect or use specified version\n\tconst version = options?.version ?? detectQtiVersion(xml);\n\n\t// Use custom mappers if provided, otherwise create appropriate ones\n\tconst mapper = options?.mapper ?? createMapperForVersion(version);\n\tconst attributeMapper = options?.attributeMapper ?? createAttributeMapperForVersion(version);\n\n\treturn {\n\t\tversion,\n\t\tmapper,\n\t\tattributeMapper,\n\t};\n}\n\n/**\n * Create element name mapper for a specific QTI version.\n *\n * @param version - QTI version\n * @returns Element name mapper for the version\n *\n * @example\n * ```typescript\n * const qti2Mapper = createMapperForVersion('2.2');\n * const qti3Mapper = createMapperForVersion('3.0');\n * ```\n */\nexport function createMapperForVersion(version: QtiVersion): ElementNameMapper {\n\tswitch (version) {\n\t\tcase '2.0':\n\t\tcase '2.1':\n\t\tcase '2.2':\n\t\t\treturn new Qti2xElementNameMapper();\n\n\t\tcase '3.0':\n\t\t\treturn new Qti3ElementNameMapper();\n\n\t\tcase 'unknown':\n\t\tdefault:\n\t\t\t// Default to QTI 2.x mapper for unknown versions\n\t\t\t// (most existing content is QTI 2.x)\n\t\t\treturn new Qti2xElementNameMapper();\n\t}\n}\n\n/**\n * Create attribute name mapper for a specific QTI version.\n *\n * @param version - QTI version\n * @returns Attribute name mapper for the version\n *\n * @example\n * ```typescript\n * const qti2AttrMapper = createAttributeMapperForVersion('2.2');\n * const qti3AttrMapper = createAttributeMapperForVersion('3.0');\n * ```\n */\nexport function createAttributeMapperForVersion(version: QtiVersion): AttributeNameMapper {\n\tswitch (version) {\n\t\tcase '2.0':\n\t\tcase '2.1':\n\t\tcase '2.2':\n\t\t\treturn new Qti2xAttributeNameMapper();\n\n\t\tcase '3.0':\n\t\t\treturn new Qti3AttributeNameMapper();\n\n\t\tcase 'unknown':\n\t\tdefault:\n\t\t\t// Default to QTI 2.x mapper for unknown versions\n\t\t\treturn new Qti2xAttributeNameMapper();\n\t}\n}\n\n/**\n * Check if XML content is QTI 3.0.\n *\n * Convenience function for quickly checking if content uses QTI 3.0.\n *\n * @param xml - QTI XML content\n * @returns true if QTI 3.0, false otherwise\n *\n * @example\n * ```typescript\n * if (isQti3(xml)) {\n * console.log('This is QTI 3.0 content');\n * }\n * ```\n */\nexport function isQti3(xml: string): boolean {\n\treturn detectQtiVersion(xml) === '3.0';\n}\n\n/**\n * Check if XML content is QTI 2.x (2.0, 2.1, or 2.2).\n *\n * @param xml - QTI XML content\n * @returns true if QTI 2.x, false otherwise\n *\n * @example\n * ```typescript\n * if (isQti2(xml)) {\n * console.log('This is QTI 2.x content');\n * }\n * ```\n */\nexport function isQti2(xml: string): boolean {\n\tconst version = detectQtiVersion(xml);\n\treturn version === '2.0' || version === '2.1' || version === '2.2';\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-qti/qti-common",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "main": "./dist/index.js",
5
5
  "devDependencies": {
6
6
  "@types/bun": "^1.3.14",