@citolab/tspci 2.5.30-beta.4 → 2.5.30-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.5.30-beta.6](/compare/v2.5.30-beta.5...v2.5.30-beta.6) (2025-02-03)
7
+
8
+ **Note:** Version bump only for package @citolab/tspci
9
+
10
+
11
+
12
+
13
+
14
+ ## [2.5.30-beta.5](/compare/v2.5.30-beta.4...v2.5.30-beta.5) (2025-02-03)
15
+
16
+ **Note:** Version bump only for package @citolab/tspci
17
+
18
+
19
+
20
+
21
+
6
22
  ## [2.5.30-beta.4](/compare/v2.5.30-beta.3...v2.5.30-beta.4) (2025-02-03)
7
23
 
8
24
  **Note:** Version bump only for package @citolab/tspci
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citolab/tspci",
3
- "version": "2.5.30-beta.4",
3
+ "version": "2.5.30-beta.6",
4
4
  "description": "an opiniated typescript ims-pci builder with tao integration",
5
5
  "author": "patrick <patrick.deklein@cito.nl>",
6
6
  "repository": "@citolab/tspci",
@@ -24,6 +24,7 @@
24
24
  "@rollup/plugin-terser": "^0.4.4",
25
25
  "@rollup/plugin-typescript": "^12.1.0",
26
26
  "@tailwindcss/nesting": "0.0.0-insiders.565cd3e",
27
+ "@tailwindcss/postcss": "^4.0.3",
27
28
  "@testing-library/dom": "^10.4.0",
28
29
  "@types/node": "^22.5.5",
29
30
  "@typescript-eslint/eslint-plugin": "^8.9.0",
@@ -50,5 +51,5 @@
50
51
  "resolutions": {
51
52
  "chokidar": "^4.0.0"
52
53
  },
53
- "gitHead": "8b22951f33e93e15da089e977a426bbc4846273d"
54
+ "gitHead": "72c387c7c038445173cd72471bf8ff66896121a7"
54
55
  }
@@ -41,8 +41,17 @@ class Pci {
41
41
 
42
42
  this.shadowdom = dom.attachShadow({ mode: "closed" });
43
43
  this.render();
44
-
45
- config.onready(this);
44
+ const event = {
45
+ interaction: this,
46
+ responseIdentifier: this.config.responseIdentifier,
47
+ valid: true,
48
+ value: this.getResponse(),
49
+ };
50
+ // dispatch a custom event to notify the Delivery System that the interaction has changed
51
+ const interactionChangedEvent = new CustomEvent("qtiInteractionChanged", {
52
+ detail: event,
53
+ });
54
+ this.shadowdom.dispatchEvent(interactionChangedEvent);
46
55
  };
47
56
 
48
57
  render = () => {
@@ -20,7 +20,9 @@ class App implements IMSpci<PropTypes> {
20
20
  private logActions: { type: string; payload: unknown }[] = []; // optional logActions
21
21
  private initialState: StateModel = { input: undefined }; // optional initial state
22
22
  constructor() {
23
- ctx && ctx.register(this);
23
+ if (ctx) {
24
+ ctx.register(this);
25
+ }
24
26
  }
25
27
 
26
28
  getInstance = (dom: HTMLElement, config: Configuration<PropTypes>, stateString: string) => {
@@ -41,7 +43,9 @@ class App implements IMSpci<PropTypes> {
41
43
  this.shadowdom = dom.attachShadow({ mode: "closed" });
42
44
  this.render();
43
45
 
44
- this.config.onready && this.config.onready(this);
46
+ if (this.config.onready) {
47
+ this.config.onready(this);
48
+ }
45
49
  };
46
50
 
47
51
  render = () => {
@@ -1,15 +1,19 @@
1
1
  import { Store } from "@citolab/preact-store";
2
2
 
3
3
  export type ActionType = "SET_INPUT" | "RESTORE_STATE";
4
- export type StateModel = { input: number };
4
+ export type StateModel = { input: number | undefined };
5
5
 
6
- export const initStore = (initialState: StateModel, restoreData?: {
7
- state?: StateModel;
8
- actions: { type: string; payload: any; timestamp?: number }[];
9
- }) => {
6
+ export const initStore = (
7
+ initialState: StateModel,
8
+ restoreData?: {
9
+ state: StateModel;
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ actions: { type: string; payload: any; timestamp?: number }[];
12
+ }
13
+ ) => {
10
14
  const store = new Store<StateModel>(initialState, restoreData);
11
- store.addReducer<{ input: number }>("SET_INPUT", (state, { input }) => {
12
- return {...state, input };
15
+ store.addReducer<{ input: number | undefined }>("SET_INPUT", (state, { input }) => {
16
+ return { ...state, input };
13
17
  });
14
18
  return store;
15
- }
19
+ };
@@ -1,8 +1,8 @@
1
1
  module.exports = {
2
2
  plugins: [
3
- require('postcss-import'),
4
- require('@tailwindcss/nesting'),
5
- require('tailwindcss'),
6
- require('autoprefixer'),
7
- ]
8
- }
3
+ require("postcss-import"),
4
+ require("@tailwindcss/nesting"),
5
+ require("@tailwindcss/postcss"),
6
+ require("autoprefixer"),
7
+ ],
8
+ };
@@ -15,7 +15,9 @@ class Pci implements IMSpci<PropTypes> {
15
15
  shadowdom: ShadowRoot | Element; // Not mandatory, but its wise to create a shadowroot
16
16
 
17
17
  constructor() {
18
- ctx && ctx.register(this); // we assume the qtiCustomInteractionContext is avaible due to the import above
18
+ if (ctx) {
19
+ ctx.register(this); // we assume the qtiCustomInteractionContext is avaible due to the import above
20
+ }
19
21
  }
20
22
 
21
23
  // First in the lifecycle of a PCI, this method is called with the domElement ( usually qti-interaction-markup ) where we can add our dom tree.
package/src/cli.js CHANGED
@@ -430,15 +430,14 @@ const run = async () => {
430
430
  }
431
431
 
432
432
  prodBuild().then(() => {
433
- if (t) {
434
- if (!targetName) {
435
- console.error("Missing target name. Use tspci --target target or tspci --targetExt target");
436
- }
437
- const scriptFile = path.join(path.join(path.join(NODE_MODULES, `${targetName}`), "src"), `createPackage.mjs`);
438
- import(`file:///${scriptFile}`).then((script) => {
439
- script.bundle();
440
- });
433
+ if (!targetName) {
434
+ console.error("Missing target name. Use tspci --target target or tspci --targetExt target");
435
+ return;
441
436
  }
437
+ const scriptFile = path.join(path.join(path.join(NODE_MODULES, `${targetName}`), "src"), `createPackage.mjs`);
438
+ import(`file:///${scriptFile}`).then((script) => {
439
+ script.bundle();
440
+ });
442
441
  });
443
442
  };
444
443
 
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // Define the payload structure for the custom event
2
2
  export interface QtiInteractionChangedDetail {
3
- interaction: IMSpci<ConfigProperties<unknown>>; // The PCI instance itself
3
+ interaction: IMSpci<unknown>; // The PCI instance itself
4
4
  responseIdentifier: string; // The response identifier provided in the getInstance call
5
5
  valid?: boolean; // Optional boolean indicating if checkValidity() returns true
6
6
  value?: QtiVariableJSON; // Optional value returned by getResponse()
@@ -14,9 +14,9 @@ export interface ConfigProperties<T> {
14
14
  boundTo: Record<string, QtiVariableJSON>; // Follows structure in Appendix C
15
15
  responseIdentifier: string; // Unique within interaction scope
16
16
 
17
- onready: (interaction: IMSpci<ConfigProperties<unknown>>, state?: string) => void; // Callback when PCI is fully constructed and ready
17
+ onready: (interaction: IMSpci<T>, state?: string) => void; // Callback when PCI is fully constructed and ready
18
18
  ondone?: (
19
- interaction: IMSpci<ConfigProperties<unknown>>,
19
+ interaction: IMSpci<T>,
20
20
  response: Record<string, QtiVariableJSON>,
21
21
  state: string,
22
22
  status?: "interacting" | "closed" | "solution" | "review"