@pie-qti/web-component-loaders 0.1.10 → 0.1.12
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 +15 -3
- package/dist/default-runtime.css +10 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -2
- package/package.json +21 -5
package/README.md
CHANGED
|
@@ -10,21 +10,32 @@ This package provides small helper functions that:
|
|
|
10
10
|
|
|
11
11
|
## Install / dependency expectations
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
It declares `@pie-qti/player-elements` and `@pie-qti/default-components` as optional peer dependencies, because the loader imports their browser registration modules at runtime.
|
|
14
|
+
It also declares `@pie-qti/theme-daisyui` as an optional peer dependency for the default runtime stylesheet.
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
## CSS
|
|
17
|
+
|
|
18
|
+
Import the default browser runtime stylesheet once from your host app:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import '@pie-qti/web-component-loaders/default-runtime.css';
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
This composes the QTI DaisyUI theme bridge and QTI shared vocabulary stylesheet.
|
|
16
25
|
|
|
17
26
|
## Usage
|
|
18
27
|
|
|
19
|
-
### Load PIE QTI
|
|
28
|
+
### Load PIE QTI player elements once (safe to call multiple times)
|
|
20
29
|
|
|
21
30
|
```ts
|
|
22
31
|
import { loadPieQtiPlayerElements } from '@pie-qti/web-component-loaders';
|
|
32
|
+
import '@pie-qti/web-component-loaders/default-runtime.css';
|
|
23
33
|
|
|
24
34
|
await loadPieQtiPlayerElements();
|
|
25
35
|
// At this point the register module was imported and we waited for:
|
|
26
36
|
// - <pie-qti-item-player>
|
|
27
37
|
// - <pie-qti-assessment-player>
|
|
38
|
+
// - the bundled default QTI interaction elements
|
|
28
39
|
```
|
|
29
40
|
|
|
30
41
|
### Using in React (example)
|
|
@@ -32,6 +43,7 @@ await loadPieQtiPlayerElements();
|
|
|
32
43
|
```ts
|
|
33
44
|
import { useEffect } from 'react';
|
|
34
45
|
import { loadPieQtiPlayerElements } from '@pie-qti/web-component-loaders';
|
|
46
|
+
import '@pie-qti/web-component-loaders/default-runtime.css';
|
|
35
47
|
|
|
36
48
|
export function QtiPlayerBoot() {
|
|
37
49
|
useEffect(() => {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Default PIE QTI browser runtime CSS.
|
|
3
|
+
*
|
|
4
|
+
* Import this once in host applications that use loadPieQtiPlayerElements().
|
|
5
|
+
* It wires host DaisyUI theme tokens into QTI components and enables QTI 3
|
|
6
|
+
* shared vocabulary classes in authored item content.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
@import '@pie-qti/theme-daisyui/bridge.css';
|
|
10
|
+
@import '@pie-qti/default-components/qti-shared-vocabulary.css';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ declare global {
|
|
|
2
2
|
var __pieQtiWebComponentLoaders__: undefined | Record<string, Promise<void>>;
|
|
3
3
|
}
|
|
4
4
|
/**
|
|
5
|
-
* Idempotently loads
|
|
5
|
+
* Idempotently loads the PIE QTI player and default interaction web components.
|
|
6
6
|
* Safe to call multiple times; the underlying import will only happen once.
|
|
7
7
|
*/
|
|
8
8
|
export declare function loadPieQtiPlayerElements(): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
const DEFAULT_INTERACTION_TAGS = [
|
|
2
|
+
'pie-qti-choice',
|
|
3
|
+
'pie-qti-slider',
|
|
4
|
+
'pie-qti-order',
|
|
5
|
+
'pie-qti-match',
|
|
6
|
+
'pie-qti-associate',
|
|
7
|
+
'pie-qti-gap-match',
|
|
8
|
+
'pie-qti-hotspot',
|
|
9
|
+
'pie-qti-hottext',
|
|
10
|
+
'pie-qti-media',
|
|
11
|
+
'pie-qti-custom',
|
|
12
|
+
'pie-qti-end-attempt',
|
|
13
|
+
'pie-qti-position-object',
|
|
14
|
+
'pie-qti-graphic-gap-match',
|
|
15
|
+
'pie-qti-graphic-order',
|
|
16
|
+
'pie-qti-graphic-associate',
|
|
17
|
+
'pie-qti-select-point',
|
|
18
|
+
'pie-qti-extended-text',
|
|
19
|
+
'pie-qti-upload',
|
|
20
|
+
'pie-qti-drawing',
|
|
21
|
+
'pie-qti-catalog-popup',
|
|
22
|
+
];
|
|
1
23
|
function getStore() {
|
|
2
24
|
const g = globalThis;
|
|
3
25
|
if (!g.__pieQtiWebComponentLoaders__)
|
|
@@ -5,20 +27,24 @@ function getStore() {
|
|
|
5
27
|
return g.__pieQtiWebComponentLoaders__;
|
|
6
28
|
}
|
|
7
29
|
/**
|
|
8
|
-
* Idempotently loads
|
|
30
|
+
* Idempotently loads the PIE QTI player and default interaction web components.
|
|
9
31
|
* Safe to call multiple times; the underlying import will only happen once.
|
|
10
32
|
*/
|
|
11
33
|
export async function loadPieQtiPlayerElements() {
|
|
12
34
|
if (typeof globalThis.window === 'undefined')
|
|
13
35
|
return;
|
|
14
36
|
const store = getStore();
|
|
15
|
-
store.pieQtiPlayerElements ??=
|
|
37
|
+
store.pieQtiPlayerElements ??= Promise.all([
|
|
38
|
+
import('@pie-qti/player-elements/register'),
|
|
39
|
+
import('@pie-qti/default-components/plugins'),
|
|
40
|
+
]).then(async () => {
|
|
16
41
|
const win = globalThis.window;
|
|
17
42
|
if (!win || typeof win.customElements === 'undefined')
|
|
18
43
|
return;
|
|
19
44
|
await Promise.allSettled([
|
|
20
45
|
win.customElements.whenDefined('pie-qti-item-player'),
|
|
21
46
|
win.customElements.whenDefined('pie-qti-assessment-player'),
|
|
47
|
+
...DEFAULT_INTERACTION_TAGS.map((tagName) => win.customElements.whenDefined(tagName)),
|
|
22
48
|
]);
|
|
23
49
|
});
|
|
24
50
|
return store.pieQtiPlayerElements;
|
package/package.json
CHANGED
|
@@ -1,29 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-qti/web-component-loaders",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@pie-qti/
|
|
6
|
+
"@pie-qti/default-components": "0.1.12",
|
|
7
|
+
"@pie-qti/player-elements": "0.1.12",
|
|
8
|
+
"@pie-qti/theme-daisyui": "0.1.12",
|
|
7
9
|
"typescript": "^5.9.3"
|
|
8
10
|
},
|
|
9
11
|
"peerDependencies": {
|
|
10
|
-
"@pie-qti/
|
|
12
|
+
"@pie-qti/default-components": "0.1.12",
|
|
13
|
+
"@pie-qti/player-elements": "0.1.12",
|
|
14
|
+
"@pie-qti/theme-daisyui": "0.1.12"
|
|
11
15
|
},
|
|
12
16
|
"exports": {
|
|
13
17
|
".": {
|
|
14
18
|
"types": "./dist/index.d.ts",
|
|
15
19
|
"import": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./default-runtime.css": {
|
|
22
|
+
"style": "./dist/default-runtime.css",
|
|
23
|
+
"default": "./dist/default-runtime.css"
|
|
16
24
|
}
|
|
17
25
|
},
|
|
18
26
|
"description": "Shared, idempotent client-side loaders for QTI-related web components used across apps",
|
|
19
27
|
"license": "MIT",
|
|
20
28
|
"peerDependenciesMeta": {
|
|
29
|
+
"@pie-qti/default-components": {
|
|
30
|
+
"optional": true
|
|
31
|
+
},
|
|
21
32
|
"@pie-qti/player-elements": {
|
|
22
33
|
"optional": true
|
|
34
|
+
},
|
|
35
|
+
"@pie-qti/theme-daisyui": {
|
|
36
|
+
"optional": true
|
|
23
37
|
}
|
|
24
38
|
},
|
|
25
39
|
"scripts": {
|
|
26
|
-
"build": "rm -rf dist tsconfig.tsbuildinfo && tsc -p ./tsconfig.json"
|
|
40
|
+
"build": "rm -rf dist tsconfig.tsbuildinfo && tsc -p ./tsconfig.json && cp src/*.css dist/"
|
|
27
41
|
},
|
|
28
42
|
"type": "module",
|
|
29
43
|
"types": "./dist/index.d.ts",
|
|
@@ -39,7 +53,9 @@
|
|
|
39
53
|
"publishConfig": {
|
|
40
54
|
"access": "public"
|
|
41
55
|
},
|
|
42
|
-
"sideEffects":
|
|
56
|
+
"sideEffects": [
|
|
57
|
+
"./dist/*.css"
|
|
58
|
+
],
|
|
43
59
|
"engines": {
|
|
44
60
|
"node": ">=20.19.0"
|
|
45
61
|
},
|