@pie-qti/item-player 0.1.21 → 0.1.23
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 +22 -0
- package/dist/core/Player.d.ts +22 -3
- package/dist/core/Player.js +32 -8
- package/dist/core/Player.js.map +1 -1
- package/dist/{element-class-iN9MRyjF.js → element-class-DBV-1lkb.js} +2032 -2057
- package/dist/element-class-DBV-1lkb.js.map +1 -0
- package/dist/element-class.d.ts +11 -0
- package/dist/element-class.js +1 -1
- package/dist/element.js +1 -1
- package/dist/element.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/pci/PciHost.d.ts +61 -2
- package/dist/pci/PciHost.js +100 -3
- package/dist/pci/PciHost.js.map +1 -1
- package/dist/pci/allowlistResolver.d.ts +45 -0
- package/dist/pci/allowlistResolver.js +72 -0
- package/dist/pci/allowlistResolver.js.map +1 -0
- package/dist/pci/index.d.ts +2 -0
- package/dist/pci/index.js +1 -0
- package/dist/pci/index.js.map +1 -1
- package/dist/pci/types.d.ts +22 -1
- package/dist/pci/types.js.map +1 -1
- package/package.json +14 -6
- package/dist/element-class-iN9MRyjF.js.map +0 -1
package/dist/pci/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/pci/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/pci/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA+IH;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IACxD,YACiB,kBAA0B,EAC1B,YAAoB;QAEpC,KAAK,CACJ,gDAAgD,kBAAkB,KAAK;YACtE,4DAA4D,YAAY,IAAI,CAC7E,CAAC;QANc,uBAAkB,GAAlB,kBAAkB,CAAQ;QAC1B,iBAAY,GAAZ,YAAY,CAAQ;QAMpC,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;IAC9C,CAAC;CACD;AAED;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACtC,YACiB,WAAmB,EACnB,YAAgC,EAChD,KAAa;QAEb,KAAK,CACJ,YAAY;YACX,CAAC,CAAC,mCAAmC,WAAW,mBAAmB,YAAY,GAAG;YAClF,CAAC,CAAC,mCAAmC,WAAW,GAAG,CACpD,CAAC;QARc,gBAAW,GAAX,WAAW,CAAQ;QACnB,iBAAY,GAAZ,YAAY,CAAoB;QAQhD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,KAAK;YAAE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;IACvG,CAAC;CACD","sourcesContent":["/**\n * QTI 3.0 Portable Custom Interaction (PCI) types.\n * Based on IMS QTI 3.0 Portable Custom Interaction specification.\n */\n\nimport type { HtmlContent } from '../types/index.js';\n\n/**\n * Callbacks the player provides to a PCI module so it can signal state changes.\n */\nexport interface PciBoundTo {\n\t/** Called when the PCI has finished initializing and is ready to accept responses. */\n\tonReady(): void;\n\t/** Called whenever the candidate's response changes. */\n\tonResponseChange(value: unknown): void;\n}\n\n/**\n * Contract that every PCI module must fulfill.\n * The module's default export (or named `getInstance` export) must implement this interface.\n */\nexport interface PciModule {\n\t/** Initialize the PCI inside the given DOM element. */\n\tinitialize(dom: HTMLElement, config: Record<string, string>, boundTo: PciBoundTo): void;\n\t/** Return the current response value. */\n\tgetResponse(): unknown;\n\t/** Restore a previously-captured response value. */\n\tsetResponse(value: unknown): void;\n\t/** Disable candidate interaction (e.g. after submission or when role is not candidate). */\n\tdisable(): void;\n\t/** Re-enable candidate interaction. */\n\tenable(): void;\n\t/** Tear down: remove event listeners, cancel timers, free resources. */\n\tdestroy(): void;\n}\n\n/** Identifies which authored module path is currently being resolved. */\nexport type PciModulePathKind = 'primary' | 'fallback';\n\n/**\n * Context supplied to a host-owned PCI module resolver.\n *\n * PCI code executes with the authority of the page that loads it. The player therefore\n * never imports an authored URL by itself; an embedding host must decide which URLs or\n * package resources are trusted and return the loaded module explicitly.\n */\nexport interface PciModuleResolutionContext {\n\t/** Original path exactly as authored in the item. */\n\tauthoredPath: string;\n\t/** Whether this is the primary module or the authored fallback. */\n\tkind: PciModulePathKind;\n\t/** Response variable bound to the interaction. */\n\tresponseIdentifier: string;\n\t/** Portable interaction type identifier/URN. */\n\tcustomInteractionTypeIdentifier: string;\n}\n\n/**\n * Host-controlled PCI module resolution hook.\n *\n * The resolver may import an allow-listed URL, read a module from a verified content\n * package, or return a pre-registered module. Its return value may be a PciModule,\n * an ES-module namespace with a default export, or a namespace exposing getInstance().\n */\nexport type PciModuleResolver = (\n\tresolvedUrl: string,\n\tcontext: PciModuleResolutionContext\n) => Promise<unknown> | unknown;\n\n/** Secure-by-default PCI runtime configuration. */\nexport interface PciConfiguration {\n\t/** Directory URL used to resolve relative authored module paths. */\n\tbaseUrl?: string;\n\t/** Required host trust decision for loading/executing a PCI module. */\n\tmoduleResolver: PciModuleResolver;\n}\n\n/**\n * Low-level options accepted by PciHost.\n *\n * `moduleResolver` remains optional here so an unconfigured host can report the\n * secure-default error at load time. Public player configuration requires it.\n */\nexport interface PciHostOptions {\n\tbaseUrl?: string;\n\tmoduleResolver?: PciModuleResolver;\n}\n\n/**\n * Public, structural contract exposed by a PCI host.\n *\n * Keep component boundaries typed against this interface rather than the concrete\n * PciHost class. That allows consumers to combine source and published package\n * entrypoints without TypeScript treating the class's private state as part of\n * the compatibility check.\n */\nexport interface PciHostController {\n\tonResponseChange(callback: (responseId: string, value: unknown) => void): () => void;\n\t/**\n\t * Fired when an authoritative `restore()` lands on a mounted module. The\n\t * renderer owns scaffold sanitization, so it resets the markup and calls\n\t * `remount()`.\n\t */\n\tonRemountRequest(callback: () => void): () => void;\n\tload(): Promise<void>;\n\tinitialize(dom: HTMLElement): void;\n\t/** Rebuild the module in place from the held response, after a scaffold reset. */\n\tremount(dom: HTMLElement): Promise<void>;\n\tgetResponse(): unknown;\n\t/**\n\t * Offer a response the player believes to be current. Declined, returning\n\t * `false`, once a mounted module has reported a response of its own: a live\n\t * interaction owns its response until something authoritative replaces it.\n\t */\n\tofferResponse(value: unknown): boolean;\n\t/**\n\t * Authoritatively replace the response, discarding in-progress candidate\n\t * state and returning ownership to the player. Session restore, reset to\n\t * declaration default, and explicit host overrides use this. A mounted module\n\t * is rebuilt through `onRemountRequest` where a renderer is wired to it, and\n\t * otherwise receives the value directly.\n\t */\n\trestore(value: unknown): void;\n\tdisable(): void;\n\tenable(): void;\n\tdestroy(): void;\n}\n\n/**\n * Extracted data from a <qti-portable-custom-interaction> element.\n */\nexport interface ExtractedPci {\n\t/** responseIdentifier attribute value. */\n\tresponseIdentifier: string;\n\t/** customInteractionTypeIdentifier attribute value (URN identifying the PCI type). */\n\tcustomInteractionTypeIdentifier: string;\n\t/** Primary JS module path (required). */\n\tprimaryPath: string;\n\t/** Fallback JS module path (optional). */\n\tfallbackPath?: string;\n\t/** Inner HTML of the <qti-interaction-markup> element. */\n\tmarkup: HtmlContent;\n\t/** Key/value pairs from <qti-pci-properties>/<qti-pci-property>. */\n\tconfig: Record<string, string>;\n}\n\n/**\n * Raised when PCI content is present but the embedding host has not opted into executing it.\n */\nexport class PciModuleResolverRequiredError extends Error {\n\tconstructor(\n\t\tpublic readonly responseIdentifier: string,\n\t\tpublic readonly authoredPath: string\n\t) {\n\t\tsuper(\n\t\t\t`PCI module loading is disabled for response '${responseIdentifier}'. ` +\n\t\t\t\t`Provide a host-controlled moduleResolver before loading '${authoredPath}'.`\n\t\t);\n\t\tthis.name = 'PciModuleResolverRequiredError';\n\t}\n}\n\n/**\n * Thrown when a PCI module fails to load from both primary and fallback paths.\n */\nexport class PciLoadError extends Error {\n\tconstructor(\n\t\tpublic readonly primaryPath: string,\n\t\tpublic readonly fallbackPath: string | undefined,\n\t\tcause?: Error\n\t) {\n\t\tsuper(\n\t\t\tfallbackPath\n\t\t\t\t? `PCI module failed to load from '${primaryPath}' and fallback '${fallbackPath}'`\n\t\t\t\t: `PCI module failed to load from '${primaryPath}'`\n\t\t);\n\t\tthis.name = 'PciLoadError';\n\t\tif (cause) Object.defineProperty(this, 'cause', { value: cause, writable: true, configurable: true });\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-qti/item-player",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
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,21 +27,29 @@
|
|
|
27
27
|
],
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@pie-qti/
|
|
31
|
-
"@pie-qti/
|
|
32
|
-
"@pie-qti/qti-
|
|
33
|
-
"@pie-qti/qti-processing": "0.1.21",
|
|
30
|
+
"@pie-qti/ims-cp-core": "0.1.23",
|
|
31
|
+
"@pie-qti/qti-common": "0.1.23",
|
|
32
|
+
"@pie-qti/qti-processing": "0.1.23",
|
|
34
33
|
"mathlive": "^0.110.0",
|
|
35
34
|
"node-html-parser": "^9.0.1"
|
|
36
35
|
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@pie-qti/i18n": "0.1.23"
|
|
38
|
+
},
|
|
39
|
+
"peerDependenciesMeta": {
|
|
40
|
+
"@pie-qti/i18n": {
|
|
41
|
+
"optional": true
|
|
42
|
+
}
|
|
43
|
+
},
|
|
37
44
|
"devDependencies": {
|
|
38
45
|
"@biomejs/biome": "^2.5.7",
|
|
46
|
+
"@pie-qti/i18n": "0.1.23",
|
|
39
47
|
"@sveltejs/vite-plugin-svelte": "^7.3.0",
|
|
40
48
|
"@types/node": "^26.2.0",
|
|
41
49
|
"svelte": "^5.56.8",
|
|
42
50
|
"svelte-check": "^4.7.5",
|
|
43
51
|
"typescript": "^5.9.3",
|
|
44
|
-
"vite": "^8.
|
|
52
|
+
"vite": "^8.2.1",
|
|
45
53
|
"vite-plugin-dts": "^5.0.3"
|
|
46
54
|
},
|
|
47
55
|
"exports": {
|