@pie-qti/assessment-player 1.0.0-beta.4 → 1.0.0-beta.5
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 +28 -7
- package/dist/components/createPlayerConnection.svelte.d.ts +90 -0
- package/dist/components/createPlayerConnection.svelte.js +151 -0
- package/dist/components/createPlayerConnection.svelte.js.map +1 -0
- package/dist/components/displaySettings.svelte.d.ts +23 -0
- package/dist/components/displaySettings.svelte.js +40 -0
- package/dist/components/displaySettings.svelte.js.map +1 -0
- package/dist/components/srOnly.d.ts +29 -0
- package/dist/components/srOnly.js +55 -0
- package/dist/components/srOnly.js.map +1 -0
- package/dist/components/submitDialogAction.d.ts +25 -0
- package/dist/components/submitDialogAction.js +89 -0
- package/dist/components/submitDialogAction.js.map +1 -0
- package/dist/core/AssessmentPlayer.d.ts +1102 -53
- package/dist/core/AssessmentPlayer.js +2836 -457
- package/dist/core/AssessmentPlayer.js.map +1 -1
- package/dist/core/AssessmentSessionCoordinator.d.ts +76 -7
- package/dist/core/AssessmentSessionCoordinator.js +185 -10
- package/dist/core/AssessmentSessionCoordinator.js.map +1 -1
- package/dist/core/AutosaveManager.d.ts +104 -0
- package/dist/core/AutosaveManager.js +181 -0
- package/dist/core/AutosaveManager.js.map +1 -0
- package/dist/core/ItemSessionController.d.ts +17 -26
- package/dist/core/ItemSessionController.js +33 -73
- package/dist/core/ItemSessionController.js.map +1 -1
- package/dist/core/NavigationManager.d.ts +18 -50
- package/dist/core/NavigationManager.js +21 -83
- package/dist/core/NavigationManager.js.map +1 -1
- package/dist/core/TimeManager.d.ts +62 -16
- package/dist/core/TimeManager.js +148 -57
- package/dist/core/TimeManager.js.map +1 -1
- package/dist/core/autosave.d.ts +44 -0
- package/dist/core/autosave.js +46 -0
- package/dist/core/autosave.js.map +1 -0
- package/dist/core/deliveryStructure.d.ts +54 -0
- package/dist/core/deliveryStructure.js +72 -0
- package/dist/core/deliveryStructure.js.map +1 -0
- package/dist/core/errors.d.ts +116 -0
- package/dist/core/errors.js +77 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/exitBoundaries.d.ts +64 -0
- package/dist/core/exitBoundaries.js +98 -0
- package/dist/core/exitBoundaries.js.map +1 -0
- package/dist/core/feedback.d.ts +46 -0
- package/dist/core/feedback.js +47 -0
- package/dist/core/feedback.js.map +1 -0
- package/dist/core/formatTime.d.ts +8 -0
- package/dist/core/formatTime.js +20 -0
- package/dist/core/formatTime.js.map +1 -0
- package/dist/core/index.d.ts +7 -4
- package/dist/core/index.js +4 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/navigationPolicy.d.ts +46 -0
- package/dist/core/navigationPolicy.js +66 -0
- package/dist/core/navigationPolicy.js.map +1 -0
- package/dist/core/pause.d.ts +58 -0
- package/dist/core/pause.js +101 -0
- package/dist/core/pause.js.map +1 -0
- package/dist/core/playerEvents.d.ts +51 -0
- package/dist/core/playerEvents.js +66 -0
- package/dist/core/playerEvents.js.map +1 -0
- package/dist/core/reviewState.d.ts +81 -0
- package/dist/core/reviewState.js +113 -0
- package/dist/core/reviewState.js.map +1 -0
- package/dist/core/reviewViews.d.ts +43 -0
- package/dist/core/reviewViews.js +88 -0
- package/dist/core/reviewViews.js.map +1 -0
- package/dist/core/scopeLocks.d.ts +36 -0
- package/dist/core/scopeLocks.js +78 -0
- package/dist/core/scopeLocks.js.map +1 -0
- package/dist/core/sessionRecords.d.ts +31 -0
- package/dist/core/sessionRecords.js +74 -0
- package/dist/core/sessionRecords.js.map +1 -0
- package/dist/core/submissionPolicy.d.ts +65 -0
- package/dist/core/submissionPolicy.js +71 -0
- package/dist/core/submissionPolicy.js.map +1 -0
- package/dist/core/templateDefaults.d.ts +26 -0
- package/dist/core/templateDefaults.js +54 -0
- package/dist/core/templateDefaults.js.map +1 -0
- package/dist/core/testStructure.d.ts +118 -3
- package/dist/core/testStructure.js +255 -6
- package/dist/core/testStructure.js.map +1 -1
- package/dist/core/timePolicy.d.ts +40 -0
- package/dist/core/timePolicy.js +106 -0
- package/dist/core/timePolicy.js.map +1 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/integration/ReferenceBackendAdapter.d.ts +64 -101
- package/dist/integration/ReferenceBackendAdapter.js +214 -1033
- package/dist/integration/ReferenceBackendAdapter.js.map +1 -1
- package/dist/integration/api-contract.d.ts +175 -10
- package/dist/integration/api-contract.js.map +1 -1
- package/dist/integration/assessment-item-scorer.d.ts +56 -5
- package/dist/integration/assessment-item-scorer.js +116 -13
- package/dist/integration/assessment-item-scorer.js.map +1 -1
- package/dist/integration/index.d.ts +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/integration/index.js.map +1 -1
- package/dist/integration/qti-test-parser.d.ts +44 -0
- package/dist/integration/qti-test-parser.js +558 -0
- package/dist/integration/qti-test-parser.js.map +1 -0
- package/dist/integration/session-store.d.ts +54 -0
- package/dist/integration/session-store.js +75 -0
- package/dist/integration/session-store.js.map +1 -0
- package/dist/integration/test-navigation.d.ts +23 -0
- package/dist/integration/test-navigation.js +32 -0
- package/dist/integration/test-navigation.js.map +1 -0
- package/dist/integration/toSectionComposition.js +8 -1
- package/dist/integration/toSectionComposition.js.map +1 -1
- package/dist/reporting/index.d.ts +3 -0
- package/dist/reporting/index.js +3 -0
- package/dist/reporting/index.js.map +1 -0
- package/dist/reporting/inferBaseType.d.ts +13 -0
- package/dist/reporting/inferBaseType.js +26 -0
- package/dist/reporting/inferBaseType.js.map +1 -0
- package/dist/reporting/serializeAssessmentResult.d.ts +27 -0
- package/dist/reporting/serializeAssessmentResult.js +377 -0
- package/dist/reporting/serializeAssessmentResult.js.map +1 -0
- package/dist/reporting/toAssessmentResultXml.d.ts +39 -0
- package/dist/reporting/toAssessmentResultXml.js +304 -0
- package/dist/reporting/toAssessmentResultXml.js.map +1 -0
- package/dist/reporting/types.d.ts +85 -0
- package/dist/reporting/types.js +8 -0
- package/dist/reporting/types.js.map +1 -0
- package/dist/types/index.d.ts +96 -9
- package/dist/types/index.js.map +1 -1
- package/package.json +19 -13
- package/dist/core/StatePersistenceManager.d.ts +0 -125
- package/dist/core/StatePersistenceManager.js +0 -268
- package/dist/core/StatePersistenceManager.js.map +0 -1
- package/dist/utils/PerformanceMonitor.d.ts +0 -114
- package/dist/utils/PerformanceMonitor.js +0 -172
- package/dist/utils/PerformanceMonitor.js.map +0 -1
package/README.md
CHANGED
|
@@ -45,6 +45,11 @@ The element also exposes `next()`, `previous()`, `navigateTo()`, `navigateToSect
|
|
|
45
45
|
`getResponses()`, `getState()`, and `restoreState()`. Its public properties and events are documented
|
|
46
46
|
in [`@pie-qti/player-elements`](../player-elements/README.md).
|
|
47
47
|
|
|
48
|
+
`showSections`, `allowSectionNavigation` and `showProgress` are shell-presentation options: the
|
|
49
|
+
headless core ignores them, the bundled shell renders from them, and omitting any of them means
|
|
50
|
+
shown/enabled — set `false` to hide the section menu, to disable its entries, or to hide the
|
|
51
|
+
progress indicator.
|
|
52
|
+
|
|
48
53
|
### Explicit reference/preview mode
|
|
49
54
|
|
|
50
55
|
Raw assessment XML is a demo and offline-preview path. Enable it explicitly before assigning XML:
|
|
@@ -171,7 +176,20 @@ XML, own authoritative scoring state, and validate every client submission. See
|
|
|
171
176
|
If validation or the backend request fails, the player restores the pre-submit item-session
|
|
172
177
|
snapshot so the candidate can retry.
|
|
173
178
|
- In `individual` mode, `next()` submits the current item before navigating and honors the backend's
|
|
174
|
-
`nextItemIdentifier` branch decision.
|
|
179
|
+
`nextItemIdentifier` branch decision. A practice check (`checkCurrentItem()`) stays on the item and
|
|
180
|
+
keeps that decision: moving on with the response unchanged follows it without submitting again.
|
|
181
|
+
Any later counted submission voids the kept decision, so the delivery rules re-evaluate on the
|
|
182
|
+
moved outcomes, and the decision is part of the saved session state — a resumed session lands
|
|
183
|
+
exactly where the live one would. Leaving a simultaneous part on Next submits the part's pending
|
|
184
|
+
responses first and then follows the decision returned for the part's last item.
|
|
185
|
+
A move with no backend decision (a jump into the next test part, or a simultaneous-part crossing
|
|
186
|
+
whose decision led nowhere) applies the test's branch rules and preconditions with the reference
|
|
187
|
+
rules, so a test part whose precondition fails is never entered. The end of the test never
|
|
188
|
+
navigates: `submit()` (and a time expiry's or a proctor's end) collects where the candidate stands
|
|
189
|
+
and keeps a branch decision its own submission returns on record instead of following it.
|
|
190
|
+
- A practice item reopens for its remaining attempts from the attempt the backend accepted (its
|
|
191
|
+
attempt count included, so attempt k runs response processing as attempt k); once the test ends,
|
|
192
|
+
every item session is closed.
|
|
175
193
|
- In `simultaneous` mode, `submit()` sends every unsubmitted item before finalization while preserving
|
|
176
194
|
responses and serialized item sessions across backend state replacements.
|
|
177
195
|
- `submit()` finishes by calling `finalizeAssessment()` and returns `AssessmentResults`.
|
|
@@ -190,8 +208,11 @@ the part is current and its `atEnd` once the candidate has moved past it or the
|
|
|
190
208
|
`onTestFeedbackChange(listener)` reports each change and returns an unsubscribe function.
|
|
191
209
|
|
|
192
210
|
The optional `sendItemSessionToBackend` flag includes the rich serialized item-session snapshot in
|
|
193
|
-
submission requests.
|
|
194
|
-
|
|
211
|
+
submission requests. A backend that scores from that snapshot declares `requiresItemSession` and
|
|
212
|
+
always receives it: `ReferenceBackendAdapter` (reference/preview mode) does, so a templated item is
|
|
213
|
+
scored against the instance the candidate saw and an adaptive item's outcomes are taken as
|
|
214
|
+
submitted. Treat that snapshot as untrusted client save data; a production backend should validate
|
|
215
|
+
it against server-owned source and state.
|
|
195
216
|
|
|
196
217
|
## Core configuration
|
|
197
218
|
|
|
@@ -200,10 +221,10 @@ validate it against server-owned source and state.
|
|
|
200
221
|
- `backend: BackendAdapter`
|
|
201
222
|
- `initSession: InitSessionRequest`
|
|
202
223
|
|
|
203
|
-
It also accepts definition plugins, security and PCI policy, PNP, i18n, deterministic
|
|
204
|
-
host/tool configuration, display hints, timing warnings, and
|
|
205
|
-
`onItemChange()`, `onSectionChange()`, `onResponseChange()`, `onComplete()`, and timing
|
|
206
|
-
methods when lifecycle-managed unsubscription is useful.
|
|
224
|
+
It also accepts definition plugins, security and PCI policy, PNP, i18n, a deterministic clock
|
|
225
|
+
(`now`), section host/tool configuration, display hints, timing warnings, and lifecycle callbacks.
|
|
226
|
+
Prefer the `onItemChange()`, `onSectionChange()`, `onResponseChange()`, `onComplete()`, and timing
|
|
227
|
+
subscription methods when lifecycle-managed unsubscription is useful.
|
|
207
228
|
|
|
208
229
|
Definition plugins use `AssessmentItemDefinitionPlugin` from `@pie-qti/item-player` and are applied
|
|
209
230
|
to every item definition created by the assessment player.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shell's connection to the headless player: creation, event wiring,
|
|
3
|
+
* teardown, retry and the slow-load status. The shell keeps the session state
|
|
4
|
+
* (dialogs, focus, completion) and hands this composable its handlers — the
|
|
5
|
+
* bodies of the old `initialize()` listeners, moved verbatim.
|
|
6
|
+
*/
|
|
7
|
+
import type { I18nProvider } from '@pie-qti/i18n';
|
|
8
|
+
import { AssessmentPlayer, type AssessmentTimeExpiryEvent, type BackendAssessmentPlayerConfig, type ScopeTimeExpiryEvent } from '../core/AssessmentPlayer.js';
|
|
9
|
+
import type { AutosaveState } from '../core/AutosaveManager.js';
|
|
10
|
+
import type { AssessmentResults } from '../types/index.js';
|
|
11
|
+
import type { BackendAdapter, InitSessionRequest } from '../integration/api-contract.js';
|
|
12
|
+
/** A localized, candidate-safe failure of the load or of an item entry. */
|
|
13
|
+
export interface PlayerLoadError {
|
|
14
|
+
message: string;
|
|
15
|
+
supportCode: string | null;
|
|
16
|
+
}
|
|
17
|
+
/** The shell's handlers: core events → shell state. */
|
|
18
|
+
export interface PlayerConnectionHandlers {
|
|
19
|
+
onItemChange: (index: number, total: number) => void | Promise<void>;
|
|
20
|
+
onSectionChange: (index: number, total: number) => void;
|
|
21
|
+
onTestFeedbackChange: () => void;
|
|
22
|
+
onResponseChange: (responses: Record<string, unknown>) => void;
|
|
23
|
+
onBusyChange: (busy: boolean) => void;
|
|
24
|
+
onFlagChange: (itemIdentifier: string, flagged: boolean) => void;
|
|
25
|
+
onAutosaveChange: (state: AutosaveState) => void;
|
|
26
|
+
onComplete: (results: AssessmentResults) => void;
|
|
27
|
+
onTimeExpired: (event: AssessmentTimeExpiryEvent) => void;
|
|
28
|
+
onScopeTimeExpired: (event: ScopeTimeExpiryEvent) => void;
|
|
29
|
+
onPauseChange: (paused: boolean, reason?: string) => void;
|
|
30
|
+
}
|
|
31
|
+
/** The creation inputs, read once per `initialize()` from the shell's props. */
|
|
32
|
+
export interface PlayerConnectionInputs {
|
|
33
|
+
backend: BackendAdapter;
|
|
34
|
+
initSession: InitSessionRequest;
|
|
35
|
+
/** The host's config, spread into the core config verbatim. */
|
|
36
|
+
config: Partial<BackendAssessmentPlayerConfig>;
|
|
37
|
+
beginGate: boolean;
|
|
38
|
+
autosave: boolean | undefined;
|
|
39
|
+
autosaveIntervalMs: number | undefined;
|
|
40
|
+
}
|
|
41
|
+
export interface PlayerConnectionOptions {
|
|
42
|
+
/** The shell's props, read when the session is created. */
|
|
43
|
+
inputs: () => PlayerConnectionInputs;
|
|
44
|
+
/** The provider the core retains (the shell's stable i18n proxy). */
|
|
45
|
+
i18nProvider: I18nProvider;
|
|
46
|
+
/** Localize a thrown failure for the failure screen. */
|
|
47
|
+
localizeError: (err: unknown) => PlayerLoadError;
|
|
48
|
+
/** The shell's announcer. */
|
|
49
|
+
announce: (message: string, duration?: number, level?: 'polite' | 'assertive') => void;
|
|
50
|
+
/**
|
|
51
|
+
* The shell's part of the core's `onError` hook: a failed item entry (the
|
|
52
|
+
* first item, or an expiry hop) additionally routes to the shell's typed
|
|
53
|
+
* failure screen instead of an eternal bare loading state.
|
|
54
|
+
*/
|
|
55
|
+
onPlayerError: (err: unknown) => void;
|
|
56
|
+
/** Core events → shell state. */
|
|
57
|
+
handlers: PlayerConnectionHandlers;
|
|
58
|
+
/**
|
|
59
|
+
* Post-create shell sync: the restored pause, the terminal restored-finalized
|
|
60
|
+
* view, the sections. Runs before the core events are wired.
|
|
61
|
+
*/
|
|
62
|
+
onSessionCreated: (player: AssessmentPlayer) => void;
|
|
63
|
+
/**
|
|
64
|
+
* The session is live: enter the first item and settle the shell (initial
|
|
65
|
+
* navigation, resume prompt, restored-pause announcement). Runs after the
|
|
66
|
+
* core events are wired.
|
|
67
|
+
*/
|
|
68
|
+
onSessionLive: (player: AssessmentPlayer) => Promise<void>;
|
|
69
|
+
}
|
|
70
|
+
export declare function createPlayerConnection(options: PlayerConnectionOptions): {
|
|
71
|
+
/** Reactive connection state. */
|
|
72
|
+
state: {
|
|
73
|
+
player: AssessmentPlayer | null;
|
|
74
|
+
error: PlayerLoadError | null;
|
|
75
|
+
initializing: boolean;
|
|
76
|
+
/** Loading is taking long: a polite status, never a permanent error on its own. */
|
|
77
|
+
stillLoading: boolean;
|
|
78
|
+
hasFirstItem: boolean;
|
|
79
|
+
/** The begin gate holds delivery: the core was created without starting it. */
|
|
80
|
+
startPending: boolean;
|
|
81
|
+
};
|
|
82
|
+
initialize: () => Promise<void>;
|
|
83
|
+
/** Unmount: stop the slow-load timer and destroy the player. */
|
|
84
|
+
destroy: () => void;
|
|
85
|
+
/** Tear the player down without touching the timer (retry a failed load). */
|
|
86
|
+
teardown: () => void;
|
|
87
|
+
/** Clear the pending still-loading status timer. */
|
|
88
|
+
clearStillLoadingTimer: () => void;
|
|
89
|
+
};
|
|
90
|
+
export type PlayerConnection = ReturnType<typeof createPlayerConnection>;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { AssessmentPlayer, } from '../core/AssessmentPlayer.js';
|
|
2
|
+
export function createPlayerConnection(options) {
|
|
3
|
+
const state = $state({
|
|
4
|
+
player: null,
|
|
5
|
+
error: null,
|
|
6
|
+
initializing: false,
|
|
7
|
+
/** Loading is taking long: a polite status, never a permanent error on its own. */
|
|
8
|
+
stillLoading: false,
|
|
9
|
+
hasFirstItem: false,
|
|
10
|
+
/** The begin gate holds delivery: the core was created without starting it. */
|
|
11
|
+
startPending: false,
|
|
12
|
+
});
|
|
13
|
+
// Initialize the player; a retry runs this again after a load failure. A slow
|
|
14
|
+
// load is a polite status ("still loading"), never a permanent error: if the
|
|
15
|
+
// backend recovers later, the shell proceeds on its own.
|
|
16
|
+
let stillLoadingTimer = null;
|
|
17
|
+
/**
|
|
18
|
+
* Bumped by every teardown: an `initialize()` whose `AssessmentPlayer.create()`
|
|
19
|
+
* resolves after one is stale. Without this, a shell unmounted (or torn down for
|
|
20
|
+
* a retry) while creation was in flight would adopt the resolved player — fully
|
|
21
|
+
* wired and stored — and nothing would ever destroy it (its TimeManager interval
|
|
22
|
+
* would tick forever).
|
|
23
|
+
*/
|
|
24
|
+
let teardownGeneration = 0;
|
|
25
|
+
function clearStillLoadingTimer() {
|
|
26
|
+
if (stillLoadingTimer) {
|
|
27
|
+
clearTimeout(stillLoadingTimer);
|
|
28
|
+
stillLoadingTimer = null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function armStillLoadingTimer() {
|
|
32
|
+
clearStillLoadingTimer();
|
|
33
|
+
// Behind a begin gate the start screen is the expected view, not a slow load.
|
|
34
|
+
stillLoadingTimer = setTimeout(() => {
|
|
35
|
+
stillLoadingTimer = null;
|
|
36
|
+
if (!state.hasFirstItem && !state.error && !state.startPending) {
|
|
37
|
+
state.stillLoading = true;
|
|
38
|
+
}
|
|
39
|
+
}, 10000);
|
|
40
|
+
}
|
|
41
|
+
/** Tear the half-created (or live) player down; the shell re-initializes after. */
|
|
42
|
+
function teardown() {
|
|
43
|
+
teardownGeneration += 1;
|
|
44
|
+
const current = state.player;
|
|
45
|
+
state.player = null;
|
|
46
|
+
current?.destroy();
|
|
47
|
+
}
|
|
48
|
+
/** Unmount: stop the slow-load timer and destroy the player. */
|
|
49
|
+
function destroy() {
|
|
50
|
+
clearStillLoadingTimer();
|
|
51
|
+
teardown();
|
|
52
|
+
}
|
|
53
|
+
/** The core config, built from the shell's props and the host's config. */
|
|
54
|
+
function buildPlayerConfig() {
|
|
55
|
+
const { backend, initSession, config, beginGate, autosave, autosaveIntervalMs } = options.inputs();
|
|
56
|
+
const hostOnError = config.onError;
|
|
57
|
+
return {
|
|
58
|
+
backend,
|
|
59
|
+
initSession,
|
|
60
|
+
...config,
|
|
61
|
+
beginGate: beginGate || config.beginGate === true,
|
|
62
|
+
i18nProvider: options.i18nProvider,
|
|
63
|
+
...(autosave === undefined ? {} : { autosave }),
|
|
64
|
+
...(autosaveIntervalMs === undefined ? {} : { autosaveIntervalMs }),
|
|
65
|
+
// The host's error hook stays; a failed item entry (the first item, or an
|
|
66
|
+
// expiry hop) additionally routes to the shell's typed failure screen instead
|
|
67
|
+
// of an eternal bare loading state.
|
|
68
|
+
onError: (err) => {
|
|
69
|
+
hostOnError?.(err);
|
|
70
|
+
options.onPlayerError(err);
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** Subscribe the shell's handlers to the core's events. */
|
|
75
|
+
function wireCoreEvents(created) {
|
|
76
|
+
created.onItemChange(options.handlers.onItemChange);
|
|
77
|
+
created.onSectionChange(options.handlers.onSectionChange);
|
|
78
|
+
created.onTestFeedbackChange(options.handlers.onTestFeedbackChange);
|
|
79
|
+
created.onResponseChange(options.handlers.onResponseChange);
|
|
80
|
+
created.onBusyChange(options.handlers.onBusyChange);
|
|
81
|
+
created.onFlagChange(options.handlers.onFlagChange);
|
|
82
|
+
created.onAutosaveChange(options.handlers.onAutosaveChange);
|
|
83
|
+
created.onComplete(options.handlers.onComplete);
|
|
84
|
+
created.onTimeExpired(options.handlers.onTimeExpired);
|
|
85
|
+
created.onScopeTimeExpired(options.handlers.onScopeTimeExpired);
|
|
86
|
+
created.onPauseChange(options.handlers.onPauseChange);
|
|
87
|
+
}
|
|
88
|
+
async function initialize() {
|
|
89
|
+
if (state.initializing)
|
|
90
|
+
return;
|
|
91
|
+
state.initializing = true;
|
|
92
|
+
state.error = null;
|
|
93
|
+
state.stillLoading = false;
|
|
94
|
+
armStillLoadingTimer();
|
|
95
|
+
try {
|
|
96
|
+
const generation = teardownGeneration;
|
|
97
|
+
const created = await AssessmentPlayer.create(buildPlayerConfig());
|
|
98
|
+
if (generation !== teardownGeneration) {
|
|
99
|
+
// The shell unmounted (or retried) while creation was in flight: state.player
|
|
100
|
+
// is still null and nothing owns the resolved player, so destroy it here —
|
|
101
|
+
// adopting it would leave its TimeManager interval ticking forever.
|
|
102
|
+
created.destroy();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
state.startPending = !created.hasStarted();
|
|
106
|
+
state.player = created;
|
|
107
|
+
// Restored-pause sync, the terminal restored-finalized view, sections.
|
|
108
|
+
options.onSessionCreated(created);
|
|
109
|
+
// A session the backend stored as finalized is terminal: delivery whose
|
|
110
|
+
// every action rejects needs no event wiring.
|
|
111
|
+
if (created.isFinalized())
|
|
112
|
+
return;
|
|
113
|
+
// An item entry that already failed during creation (the first item could
|
|
114
|
+
// not be entered) routes here: the typed failure screen replaces the bare
|
|
115
|
+
// loading state. Later entry failures (an expiry hop) report through onError.
|
|
116
|
+
if (created.hasEntryFailure()) {
|
|
117
|
+
state.error = options.localizeError(created.getEntryError());
|
|
118
|
+
state.stillLoading = false;
|
|
119
|
+
clearStillLoadingTimer();
|
|
120
|
+
options.announce(state.error.message, 3000, 'assertive');
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
// Set up event listeners, then let the shell enter the first item.
|
|
124
|
+
wireCoreEvents(created);
|
|
125
|
+
await options.onSessionLive(created);
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
console.error('Failed to initialize assessment player:', err);
|
|
129
|
+
state.error = options.localizeError(err);
|
|
130
|
+
options.announce(state.error.message, 3000, 'assertive');
|
|
131
|
+
// The failure alert is announced; focus lands on its Retry control (the
|
|
132
|
+
// error-focus effect in the shell).
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
state.initializing = false;
|
|
136
|
+
clearStillLoadingTimer();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
/** Reactive connection state. */
|
|
141
|
+
state,
|
|
142
|
+
initialize,
|
|
143
|
+
/** Unmount: stop the slow-load timer and destroy the player. */
|
|
144
|
+
destroy,
|
|
145
|
+
/** Tear the player down without touching the timer (retry a failed load). */
|
|
146
|
+
teardown,
|
|
147
|
+
/** Clear the pending still-loading status timer. */
|
|
148
|
+
clearStillLoadingTimer,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=createPlayerConnection.svelte.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPlayerConnection.svelte.js","sourceRoot":"","sources":["../../src/components/createPlayerConnection.svelte.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * The shell's connection to the headless player: creation, event wiring,\n * teardown, retry and the slow-load status. The shell keeps the session state\n * (dialogs, focus, completion) and hands this composable its handlers — the\n * bodies of the old `initialize()` listeners, moved verbatim.\n */\nimport type { I18nProvider } from '@pie-qti/i18n';\nimport {\n\tAssessmentPlayer,\n\ttype AssessmentTimeExpiryEvent,\n\ttype BackendAssessmentPlayerConfig,\n\ttype ScopeTimeExpiryEvent,\n} from '../core/AssessmentPlayer.js';\nimport type { AutosaveState } from '../core/AutosaveManager.js';\nimport type { AssessmentResults } from '../types/index.js';\nimport type { BackendAdapter, InitSessionRequest } from '../integration/api-contract.js';\n\n/** A localized, candidate-safe failure of the load or of an item entry. */\nexport interface PlayerLoadError {\n\tmessage: string;\n\tsupportCode: string | null;\n}\n\n/** The shell's handlers: core events → shell state. */\nexport interface PlayerConnectionHandlers {\n\tonItemChange: (index: number, total: number) => void | Promise<void>;\n\tonSectionChange: (index: number, total: number) => void;\n\tonTestFeedbackChange: () => void;\n\tonResponseChange: (responses: Record<string, unknown>) => void;\n\tonBusyChange: (busy: boolean) => void;\n\tonFlagChange: (itemIdentifier: string, flagged: boolean) => void;\n\tonAutosaveChange: (state: AutosaveState) => void;\n\tonComplete: (results: AssessmentResults) => void;\n\tonTimeExpired: (event: AssessmentTimeExpiryEvent) => void;\n\tonScopeTimeExpired: (event: ScopeTimeExpiryEvent) => void;\n\tonPauseChange: (paused: boolean, reason?: string) => void;\n}\n\n/** The creation inputs, read once per `initialize()` from the shell's props. */\nexport interface PlayerConnectionInputs {\n\tbackend: BackendAdapter;\n\tinitSession: InitSessionRequest;\n\t/** The host's config, spread into the core config verbatim. */\n\tconfig: Partial<BackendAssessmentPlayerConfig>;\n\t// The shell prop and the core option open the same gate / tune the same autosave.\n\tbeginGate: boolean;\n\tautosave: boolean | undefined;\n\tautosaveIntervalMs: number | undefined;\n}\n\nexport interface PlayerConnectionOptions {\n\t/** The shell's props, read when the session is created. */\n\tinputs: () => PlayerConnectionInputs;\n\t/** The provider the core retains (the shell's stable i18n proxy). */\n\ti18nProvider: I18nProvider;\n\t/** Localize a thrown failure for the failure screen. */\n\tlocalizeError: (err: unknown) => PlayerLoadError;\n\t/** The shell's announcer. */\n\tannounce: (message: string, duration?: number, level?: 'polite' | 'assertive') => void;\n\t/**\n\t * The shell's part of the core's `onError` hook: a failed item entry (the\n\t * first item, or an expiry hop) additionally routes to the shell's typed\n\t * failure screen instead of an eternal bare loading state.\n\t */\n\tonPlayerError: (err: unknown) => void;\n\t/** Core events → shell state. */\n\thandlers: PlayerConnectionHandlers;\n\t/**\n\t * Post-create shell sync: the restored pause, the terminal restored-finalized\n\t * view, the sections. Runs before the core events are wired.\n\t */\n\tonSessionCreated: (player: AssessmentPlayer) => void;\n\t/**\n\t * The session is live: enter the first item and settle the shell (initial\n\t * navigation, resume prompt, restored-pause announcement). Runs after the\n\t * core events are wired.\n\t */\n\tonSessionLive: (player: AssessmentPlayer) => Promise<void>;\n}\n\nexport function createPlayerConnection(options: PlayerConnectionOptions) {\n\tconst state = $state({\n\t\tplayer: null as AssessmentPlayer | null,\n\t\terror: null as PlayerLoadError | null,\n\t\tinitializing: false,\n\t\t/** Loading is taking long: a polite status, never a permanent error on its own. */\n\t\tstillLoading: false,\n\t\thasFirstItem: false,\n\t\t/** The begin gate holds delivery: the core was created without starting it. */\n\t\tstartPending: false,\n\t});\n\n\t// Initialize the player; a retry runs this again after a load failure. A slow\n\t// load is a polite status (\"still loading\"), never a permanent error: if the\n\t// backend recovers later, the shell proceeds on its own.\n\tlet stillLoadingTimer: ReturnType<typeof setTimeout> | null = null;\n\n\t/**\n\t * Bumped by every teardown: an `initialize()` whose `AssessmentPlayer.create()`\n\t * resolves after one is stale. Without this, a shell unmounted (or torn down for\n\t * a retry) while creation was in flight would adopt the resolved player — fully\n\t * wired and stored — and nothing would ever destroy it (its TimeManager interval\n\t * would tick forever).\n\t */\n\tlet teardownGeneration = 0;\n\n\tfunction clearStillLoadingTimer() {\n\t\tif (stillLoadingTimer) {\n\t\t\tclearTimeout(stillLoadingTimer);\n\t\t\tstillLoadingTimer = null;\n\t\t}\n\t}\n\n\tfunction armStillLoadingTimer() {\n\t\tclearStillLoadingTimer();\n\t\t// Behind a begin gate the start screen is the expected view, not a slow load.\n\t\tstillLoadingTimer = setTimeout(() => {\n\t\t\tstillLoadingTimer = null;\n\t\t\tif (!state.hasFirstItem && !state.error && !state.startPending) {\n\t\t\t\tstate.stillLoading = true;\n\t\t\t}\n\t\t}, 10000);\n\t}\n\n\t/** Tear the half-created (or live) player down; the shell re-initializes after. */\n\tfunction teardown() {\n\t\tteardownGeneration += 1;\n\t\tconst current = state.player;\n\t\tstate.player = null;\n\t\tcurrent?.destroy();\n\t}\n\n\t/** Unmount: stop the slow-load timer and destroy the player. */\n\tfunction destroy() {\n\t\tclearStillLoadingTimer();\n\t\tteardown();\n\t}\n\n\t/** The core config, built from the shell's props and the host's config. */\n\tfunction buildPlayerConfig(): BackendAssessmentPlayerConfig {\n\t\tconst { backend, initSession, config, beginGate, autosave, autosaveIntervalMs } = options.inputs();\n\t\tconst hostOnError = config.onError;\n\t\treturn {\n\t\t\tbackend,\n\t\t\tinitSession,\n\t\t\t...config,\n\t\t\tbeginGate: beginGate || config.beginGate === true,\n\t\t\ti18nProvider: options.i18nProvider,\n\t\t\t...(autosave === undefined ? {} : { autosave }),\n\t\t\t...(autosaveIntervalMs === undefined ? {} : { autosaveIntervalMs }),\n\t\t\t// The host's error hook stays; a failed item entry (the first item, or an\n\t\t\t// expiry hop) additionally routes to the shell's typed failure screen instead\n\t\t\t// of an eternal bare loading state.\n\t\t\tonError: (err) => {\n\t\t\t\thostOnError?.(err);\n\t\t\t\toptions.onPlayerError(err);\n\t\t\t},\n\t\t};\n\t}\n\n\t/** Subscribe the shell's handlers to the core's events. */\n\tfunction wireCoreEvents(created: AssessmentPlayer) {\n\t\tcreated.onItemChange(options.handlers.onItemChange);\n\t\tcreated.onSectionChange(options.handlers.onSectionChange);\n\t\tcreated.onTestFeedbackChange(options.handlers.onTestFeedbackChange);\n\t\tcreated.onResponseChange(options.handlers.onResponseChange);\n\t\tcreated.onBusyChange(options.handlers.onBusyChange);\n\t\tcreated.onFlagChange(options.handlers.onFlagChange);\n\t\tcreated.onAutosaveChange(options.handlers.onAutosaveChange);\n\t\tcreated.onComplete(options.handlers.onComplete);\n\t\tcreated.onTimeExpired(options.handlers.onTimeExpired);\n\t\tcreated.onScopeTimeExpired(options.handlers.onScopeTimeExpired);\n\t\tcreated.onPauseChange(options.handlers.onPauseChange);\n\t}\n\n\tasync function initialize() {\n\t\tif (state.initializing) return;\n\t\tstate.initializing = true;\n\t\tstate.error = null;\n\t\tstate.stillLoading = false;\n\t\tarmStillLoadingTimer();\n\n\t\ttry {\n\t\t\tconst generation = teardownGeneration;\n\t\t\tconst created = await AssessmentPlayer.create(buildPlayerConfig());\n\t\t\tif (generation !== teardownGeneration) {\n\t\t\t\t// The shell unmounted (or retried) while creation was in flight: state.player\n\t\t\t\t// is still null and nothing owns the resolved player, so destroy it here —\n\t\t\t\t// adopting it would leave its TimeManager interval ticking forever.\n\t\t\t\tcreated.destroy();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstate.startPending = !created.hasStarted();\n\t\t\tstate.player = created;\n\n\t\t\t// Restored-pause sync, the terminal restored-finalized view, sections.\n\t\t\toptions.onSessionCreated(created);\n\n\t\t\t// A session the backend stored as finalized is terminal: delivery whose\n\t\t\t// every action rejects needs no event wiring.\n\t\t\tif (created.isFinalized()) return;\n\n\t\t\t// An item entry that already failed during creation (the first item could\n\t\t\t// not be entered) routes here: the typed failure screen replaces the bare\n\t\t\t// loading state. Later entry failures (an expiry hop) report through onError.\n\t\t\tif (created.hasEntryFailure()) {\n\t\t\t\tstate.error = options.localizeError(created.getEntryError()!);\n\t\t\t\tstate.stillLoading = false;\n\t\t\t\tclearStillLoadingTimer();\n\t\t\t\toptions.announce(state.error.message, 3000, 'assertive');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Set up event listeners, then let the shell enter the first item.\n\t\t\twireCoreEvents(created);\n\t\t\tawait options.onSessionLive(created);\n\t\t} catch (err) {\n\t\t\tconsole.error('Failed to initialize assessment player:', err);\n\t\t\tstate.error = options.localizeError(err);\n\t\t\toptions.announce(state.error.message, 3000, 'assertive');\n\t\t\t// The failure alert is announced; focus lands on its Retry control (the\n\t\t\t// error-focus effect in the shell).\n\t\t} finally {\n\t\t\tstate.initializing = false;\n\t\t\tclearStillLoadingTimer();\n\t\t}\n\t}\n\n\treturn {\n\t\t/** Reactive connection state. */\n\t\tstate,\n\t\tinitialize,\n\t\t/** Unmount: stop the slow-load timer and destroy the player. */\n\t\tdestroy,\n\t\t/** Tear the player down without touching the timer (retry a failed load). */\n\t\tteardown,\n\t\t/** Clear the pending still-loading status timer. */\n\t\tclearStillLoadingTimer,\n\t};\n}\n\nexport type PlayerConnection = ReturnType<typeof createPlayerConnection>;\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Candidate display settings (PNP) for the shell chrome: the section layouts own
|
|
3
|
+
* the settings tool and report changes; the shell root is a PNP surface so the
|
|
4
|
+
* profile also covers the header, navigation and timer chrome around the item.
|
|
5
|
+
*/
|
|
6
|
+
import type { PnpProfile } from '@pie-qti/item-player';
|
|
7
|
+
import { type QtiCandidateDisplaySettings } from '@pie-qti/section-player';
|
|
8
|
+
export declare function createDisplaySettings(getHostPnp: () => PnpProfile | undefined): {
|
|
9
|
+
/** The candidate's current display settings. */
|
|
10
|
+
readonly settings: QtiCandidateDisplaySettings;
|
|
11
|
+
shellPnp: PnpProfile;
|
|
12
|
+
handleChange: (event: {
|
|
13
|
+
settings: QtiCandidateDisplaySettings;
|
|
14
|
+
}) => void;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The section layouts repaint their own surface when the candidate changes their
|
|
18
|
+
* display settings; the shell root is a separate PNP surface so the header,
|
|
19
|
+
* navigation bar and timer follow too (nested inverting filters are neutralized
|
|
20
|
+
* by the surface mechanism, and nothing outside the shell changes). Call during
|
|
21
|
+
* component initialisation: it creates the repaint effect.
|
|
22
|
+
*/
|
|
23
|
+
export declare function applyDisplaySettingsSurface(getRoot: () => HTMLElement | null, getPnp: () => PnpProfile): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { applyPnpToSurface, clearPnpSurface } from '@pie-qti/item-player';
|
|
2
|
+
import { displaySettingsOf, withDisplaySettings } from '@pie-qti/section-player';
|
|
3
|
+
export function createDisplaySettings(getHostPnp) {
|
|
4
|
+
// Seeded from the host profile: a persisted effective PNP carries the settings'
|
|
5
|
+
// fingerprints, and the chrome surface must start from the same choices the
|
|
6
|
+
// section layouts read out of it, or a resume loses its enlargements.
|
|
7
|
+
let candidate = $state(displaySettingsOf(getHostPnp()));
|
|
8
|
+
/** The profile the shell chrome renders with: the host profile with the candidate's display settings applied. */
|
|
9
|
+
const shellPnp = $derived(withDisplaySettings(getHostPnp(), candidate));
|
|
10
|
+
/** The section layouts report the candidate's changes here. */
|
|
11
|
+
function handleChange(event) {
|
|
12
|
+
candidate = event.settings;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
/** The candidate's current display settings. */
|
|
16
|
+
get settings() {
|
|
17
|
+
return candidate;
|
|
18
|
+
},
|
|
19
|
+
shellPnp,
|
|
20
|
+
handleChange,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The section layouts repaint their own surface when the candidate changes their
|
|
25
|
+
* display settings; the shell root is a separate PNP surface so the header,
|
|
26
|
+
* navigation bar and timer follow too (nested inverting filters are neutralized
|
|
27
|
+
* by the surface mechanism, and nothing outside the shell changes). Call during
|
|
28
|
+
* component initialisation: it creates the repaint effect.
|
|
29
|
+
*/
|
|
30
|
+
export function applyDisplaySettingsSurface(getRoot, getPnp) {
|
|
31
|
+
$effect(() => {
|
|
32
|
+
const root = getRoot();
|
|
33
|
+
if (!root)
|
|
34
|
+
return;
|
|
35
|
+
const pnp = getPnp();
|
|
36
|
+
applyPnpToSurface(root, pnp);
|
|
37
|
+
return () => clearPnpSurface(root);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=displaySettings.svelte.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"displaySettings.svelte.js","sourceRoot":"","sources":["../../src/components/displaySettings.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAoC,MAAM,yBAAyB,CAAC;AAEnH,MAAM,UAAU,qBAAqB,CAAC,UAAwC;IAC7E,gFAAgF;IAChF,4EAA4E;IAC5E,sEAAsE;IACtE,IAAI,SAAS,GAAG,MAAM,CAA8B,iBAAiB,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAErF,iHAAiH;IACjH,MAAM,QAAQ,GAAG,QAAQ,CAAa,mBAAmB,CAAC,UAAU,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;IAEpF,+DAA+D;IAC/D,SAAS,YAAY,CAAC,KAAgD;QACrE,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC;IAC5B,CAAC;IAED,OAAO;QACN,gDAAgD;QAChD,IAAI,QAAQ;YACX,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,QAAQ;QACR,YAAY;KACZ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CAAC,OAAiC,EAAE,MAAwB;IACtG,OAAO,CAAC,GAAG,EAAE;QACZ,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;QACvB,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;QACrB,iBAAiB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC7B,OAAO,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Candidate display settings (PNP) for the shell chrome: the section layouts own\n * the settings tool and report changes; the shell root is a PNP surface so the\n * profile also covers the header, navigation and timer chrome around the item.\n */\nimport type { PnpProfile } from '@pie-qti/item-player';\nimport { applyPnpToSurface, clearPnpSurface } from '@pie-qti/item-player';\nimport { displaySettingsOf, withDisplaySettings, type QtiCandidateDisplaySettings } from '@pie-qti/section-player';\n\nexport function createDisplaySettings(getHostPnp: () => PnpProfile | undefined) {\n\t// Seeded from the host profile: a persisted effective PNP carries the settings'\n\t// fingerprints, and the chrome surface must start from the same choices the\n\t// section layouts read out of it, or a resume loses its enlargements.\n\tlet candidate = $state<QtiCandidateDisplaySettings>(displaySettingsOf(getHostPnp()));\n\n\t/** The profile the shell chrome renders with: the host profile with the candidate's display settings applied. */\n\tconst shellPnp = $derived<PnpProfile>(withDisplaySettings(getHostPnp(), candidate));\n\n\t/** The section layouts report the candidate's changes here. */\n\tfunction handleChange(event: { settings: QtiCandidateDisplaySettings }) {\n\t\tcandidate = event.settings;\n\t}\n\n\treturn {\n\t\t/** The candidate's current display settings. */\n\t\tget settings(): QtiCandidateDisplaySettings {\n\t\t\treturn candidate;\n\t\t},\n\t\tshellPnp,\n\t\thandleChange,\n\t};\n}\n\n/**\n * The section layouts repaint their own surface when the candidate changes their\n * display settings; the shell root is a separate PNP surface so the header,\n * navigation bar and timer follow too (nested inverting filters are neutralized\n * by the surface mechanism, and nothing outside the shell changes). Call during\n * component initialisation: it creates the repaint effect.\n */\nexport function applyDisplaySettingsSurface(getRoot: () => HTMLElement | null, getPnp: () => PnpProfile) {\n\t$effect(() => {\n\t\tconst root = getRoot();\n\t\tif (!root) return;\n\t\tconst pnp = getPnp();\n\t\tapplyPnpToSurface(root, pnp);\n\t\treturn () => clearPnpSurface(root);\n\t});\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one visually hidden (`.sr-only`) rule for the shell's own chrome.
|
|
3
|
+
*
|
|
4
|
+
* The announcer's live regions and the timer's announcement regions carry the
|
|
5
|
+
* shared `sr-only` class and hide through this single rule. It is injected into
|
|
6
|
+
* the document once (light DOM: the shell and its chrome render no shadow
|
|
7
|
+
* roots), after the idiom of default-components' `shared/styles/srOnly.ts` and
|
|
8
|
+
* this package's `submitDialogAction.ts`. The shell cannot lean on the
|
|
9
|
+
* default-components injection: that rule is an import side effect of a package
|
|
10
|
+
* this one does not depend on, and a host that registers its own interactions
|
|
11
|
+
* never loads it.
|
|
12
|
+
*
|
|
13
|
+
* The declarations are identical to the canonical rule the default components
|
|
14
|
+
* inject, so with default-components loaded the two rules agree and the hidden
|
|
15
|
+
* state is the same whichever landed first. A component needing a differently
|
|
16
|
+
* scoped variant (the timer's phone-width toggle label) keeps its own
|
|
17
|
+
* media-query rule; an always-hidden element joins this rule, never a private
|
|
18
|
+
* copy of the declarations.
|
|
19
|
+
*/
|
|
20
|
+
/** The shared class any visually hidden element carries. */
|
|
21
|
+
export declare const SR_ONLY_CLASS = "sr-only";
|
|
22
|
+
/** The rule text, injected verbatim into the document. */
|
|
23
|
+
export declare const SR_ONLY_RULE: string;
|
|
24
|
+
/**
|
|
25
|
+
* Inject the rule into the document once. Safe to call repeatedly (the
|
|
26
|
+
* announcer and the timer call it from their module scripts): later calls are
|
|
27
|
+
* no-ops when the rule is already present.
|
|
28
|
+
*/
|
|
29
|
+
export declare function ensureSrOnlyStyles(): void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one visually hidden (`.sr-only`) rule for the shell's own chrome.
|
|
3
|
+
*
|
|
4
|
+
* The announcer's live regions and the timer's announcement regions carry the
|
|
5
|
+
* shared `sr-only` class and hide through this single rule. It is injected into
|
|
6
|
+
* the document once (light DOM: the shell and its chrome render no shadow
|
|
7
|
+
* roots), after the idiom of default-components' `shared/styles/srOnly.ts` and
|
|
8
|
+
* this package's `submitDialogAction.ts`. The shell cannot lean on the
|
|
9
|
+
* default-components injection: that rule is an import side effect of a package
|
|
10
|
+
* this one does not depend on, and a host that registers its own interactions
|
|
11
|
+
* never loads it.
|
|
12
|
+
*
|
|
13
|
+
* The declarations are identical to the canonical rule the default components
|
|
14
|
+
* inject, so with default-components loaded the two rules agree and the hidden
|
|
15
|
+
* state is the same whichever landed first. A component needing a differently
|
|
16
|
+
* scoped variant (the timer's phone-width toggle label) keeps its own
|
|
17
|
+
* media-query rule; an always-hidden element joins this rule, never a private
|
|
18
|
+
* copy of the declarations.
|
|
19
|
+
*/
|
|
20
|
+
/** The shared class any visually hidden element carries. */
|
|
21
|
+
export const SR_ONLY_CLASS = 'sr-only';
|
|
22
|
+
/** The declarations, identical to the canonical rule the default components inject. */
|
|
23
|
+
const DECLARATIONS = [
|
|
24
|
+
'position: absolute',
|
|
25
|
+
'width: 1px',
|
|
26
|
+
'height: 1px',
|
|
27
|
+
'padding: 0',
|
|
28
|
+
'margin: -1px',
|
|
29
|
+
'overflow: hidden',
|
|
30
|
+
'clip: rect(0, 0, 0, 0)',
|
|
31
|
+
'white-space: nowrap',
|
|
32
|
+
'border-width: 0',
|
|
33
|
+
];
|
|
34
|
+
/** The rule text, injected verbatim into the document. */
|
|
35
|
+
export const SR_ONLY_RULE = `.${SR_ONLY_CLASS} {
|
|
36
|
+
${DECLARATIONS.join(';\n\t')};
|
|
37
|
+
}`;
|
|
38
|
+
const STYLE_ATTRIBUTE = 'data-assessment-sr-only-source';
|
|
39
|
+
const STYLE_SOURCE = 'pie-qti';
|
|
40
|
+
/**
|
|
41
|
+
* Inject the rule into the document once. Safe to call repeatedly (the
|
|
42
|
+
* announcer and the timer call it from their module scripts): later calls are
|
|
43
|
+
* no-ops when the rule is already present.
|
|
44
|
+
*/
|
|
45
|
+
export function ensureSrOnlyStyles() {
|
|
46
|
+
if (typeof document === 'undefined')
|
|
47
|
+
return;
|
|
48
|
+
if (document.querySelector(`style[${STYLE_ATTRIBUTE}="${STYLE_SOURCE}"]`))
|
|
49
|
+
return;
|
|
50
|
+
const style = document.createElement('style');
|
|
51
|
+
style.setAttribute(STYLE_ATTRIBUTE, STYLE_SOURCE);
|
|
52
|
+
style.textContent = SR_ONLY_RULE;
|
|
53
|
+
document.head.appendChild(style);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=srOnly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"srOnly.js","sourceRoot":"","sources":["../../src/components/srOnly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AAEvC,uFAAuF;AACvF,MAAM,YAAY,GAAG;IACpB,oBAAoB;IACpB,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,cAAc;IACd,kBAAkB;IAClB,wBAAwB;IACxB,qBAAqB;IACrB,iBAAiB;CACjB,CAAC;AAEF,0DAA0D;AAC1D,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,aAAa;GAC1C,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC;EAC3B,CAAC;AAEH,MAAM,eAAe,GAAG,gCAAgC,CAAC;AACzD,MAAM,YAAY,GAAG,SAAS,CAAC;AAE/B;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IACjC,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO;IAC5C,IAAI,QAAQ,CAAC,aAAa,CAAC,SAAS,eAAe,KAAK,YAAY,IAAI,CAAC;QAAE,OAAO;IAClF,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9C,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;IAClD,KAAK,CAAC,WAAW,GAAG,YAAY,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC","sourcesContent":["/**\n * The one visually hidden (`.sr-only`) rule for the shell's own chrome.\n *\n * The announcer's live regions and the timer's announcement regions carry the\n * shared `sr-only` class and hide through this single rule. It is injected into\n * the document once (light DOM: the shell and its chrome render no shadow\n * roots), after the idiom of default-components' `shared/styles/srOnly.ts` and\n * this package's `submitDialogAction.ts`. The shell cannot lean on the\n * default-components injection: that rule is an import side effect of a package\n * this one does not depend on, and a host that registers its own interactions\n * never loads it.\n *\n * The declarations are identical to the canonical rule the default components\n * inject, so with default-components loaded the two rules agree and the hidden\n * state is the same whichever landed first. A component needing a differently\n * scoped variant (the timer's phone-width toggle label) keeps its own\n * media-query rule; an always-hidden element joins this rule, never a private\n * copy of the declarations.\n */\n\n/** The shared class any visually hidden element carries. */\nexport const SR_ONLY_CLASS = 'sr-only';\n\n/** The declarations, identical to the canonical rule the default components inject. */\nconst DECLARATIONS = [\n\t'position: absolute',\n\t'width: 1px',\n\t'height: 1px',\n\t'padding: 0',\n\t'margin: -1px',\n\t'overflow: hidden',\n\t'clip: rect(0, 0, 0, 0)',\n\t'white-space: nowrap',\n\t'border-width: 0',\n];\n\n/** The rule text, injected verbatim into the document. */\nexport const SR_ONLY_RULE = `.${SR_ONLY_CLASS} {\n\t${DECLARATIONS.join(';\\n\\t')};\n}`;\n\nconst STYLE_ATTRIBUTE = 'data-assessment-sr-only-source';\nconst STYLE_SOURCE = 'pie-qti';\n\n/**\n * Inject the rule into the document once. Safe to call repeatedly (the\n * announcer and the timer call it from their module scripts): later calls are\n * no-ops when the rule is already present.\n */\nexport function ensureSrOnlyStyles(): void {\n\tif (typeof document === 'undefined') return;\n\tif (document.querySelector(`style[${STYLE_ATTRIBUTE}=\"${STYLE_SOURCE}\"]`)) return;\n\tconst style = document.createElement('style');\n\tstyle.setAttribute(STYLE_ATTRIBUTE, STYLE_SOURCE);\n\tstyle.textContent = SR_ONLY_RULE;\n\tdocument.head.appendChild(style);\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one rule family for the shell dialogs' action buttons
|
|
3
|
+
* (`.submit-dialog-action`).
|
|
4
|
+
*
|
|
5
|
+
* The submit confirmation, the resume prompt and the leave-part warning render
|
|
6
|
+
* their actions into `AssessmentDialog`'s actions area through snippets, so the
|
|
7
|
+
* buttons stay in those dialogs' templates while one family here styles them
|
|
8
|
+
* all: a light-DOM injection, once per document, after the idiom of
|
|
9
|
+
* default-components' `shared/styles/srOnly.ts`. Every declaration lives here —
|
|
10
|
+
* a dialog needing a variant adds its hook below, never as a private copy of
|
|
11
|
+
* the declarations.
|
|
12
|
+
*
|
|
13
|
+
* The class also stays the theme hook: hosts and the component tests target
|
|
14
|
+
* `submit-dialog-action`, never an injected rule's internals.
|
|
15
|
+
*/
|
|
16
|
+
/** The shared class any dialog action button carries. */
|
|
17
|
+
export declare const SUBMIT_DIALOG_ACTION_CLASS = "submit-dialog-action";
|
|
18
|
+
/** The rule text, injected verbatim into the document. */
|
|
19
|
+
export declare const SUBMIT_DIALOG_ACTION_RULE = ".submit-dialog-action {\n\tbox-sizing: border-box;\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\tmin-inline-size: var(--pie-qti-control-min-size, 2.75rem);\n\tmin-block-size: var(--pie-qti-control-min-size, 2.75rem);\n\tpadding-block: var(--pie-qti-space-2, 0.5rem);\n\tpadding-inline: var(--pie-qti-space-4, 1rem);\n\tborder: 1px solid var(--pie-qti-border-strong, #767676);\n\tborder-radius: var(--pie-qti-radius, 0.5rem);\n\tbackground: var(--pie-qti-base-100, oklch(100% 0 0));\n\tcolor: var(--pie-qti-base-content, oklch(21% 0 0));\n\tfont: inherit;\n\tfont-weight: 600;\n\tline-height: 1.25;\n\ttext-align: center;\n\tcursor: pointer;\n}\n\n.submit-dialog-action:hover:not([aria-disabled='true']) {\n\tbackground: var(--pie-qti-base-200, oklch(98% 0 0));\n}\n\n.submit-dialog-action:focus-visible {\n\toutline: 2px solid var(--pie-qti-focus, #4338ca);\n\toutline-offset: 2px;\n}\n\n.submit-dialog-action[aria-disabled='true'] {\n\tcursor: not-allowed;\n\topacity: 0.6;\n}\n\n.submit-dialog-action.primary {\n\tborder-color: var(--pie-qti-primary, oklch(45% 0.24 277));\n\tbackground: var(--pie-qti-primary, oklch(45% 0.24 277));\n\tcolor: var(--pie-qti-primary-content, oklch(98% 0.01 277));\n}\n\n.submit-dialog-action.primary:hover:not([aria-disabled='true']) {\n\tbackground: color-mix(in oklab, var(--pie-qti-primary, oklch(45% 0.24 277)) 85%, black);\n}\n\n.submit-dialog-action.danger {\n\tborder-color: var(--pie-qti-error-text, #b91c1c);\n\tbackground: var(--pie-qti-error-text, #b91c1c);\n\tcolor: oklch(98% 0.01 277);\n}\n\n.submit-dialog-action.danger:hover:not([aria-disabled='true']) {\n\tbackground: color-mix(in oklab, var(--pie-qti-error-text, #b91c1c) 85%, black);\n}";
|
|
20
|
+
/**
|
|
21
|
+
* Inject the rule into the document once. Safe to call repeatedly (the dialogs
|
|
22
|
+
* call it from their module scripts): later calls are no-ops when the rule is
|
|
23
|
+
* already present.
|
|
24
|
+
*/
|
|
25
|
+
export declare function ensureSubmitDialogActionStyles(): void;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one rule family for the shell dialogs' action buttons
|
|
3
|
+
* (`.submit-dialog-action`).
|
|
4
|
+
*
|
|
5
|
+
* The submit confirmation, the resume prompt and the leave-part warning render
|
|
6
|
+
* their actions into `AssessmentDialog`'s actions area through snippets, so the
|
|
7
|
+
* buttons stay in those dialogs' templates while one family here styles them
|
|
8
|
+
* all: a light-DOM injection, once per document, after the idiom of
|
|
9
|
+
* default-components' `shared/styles/srOnly.ts`. Every declaration lives here —
|
|
10
|
+
* a dialog needing a variant adds its hook below, never as a private copy of
|
|
11
|
+
* the declarations.
|
|
12
|
+
*
|
|
13
|
+
* The class also stays the theme hook: hosts and the component tests target
|
|
14
|
+
* `submit-dialog-action`, never an injected rule's internals.
|
|
15
|
+
*/
|
|
16
|
+
/** The shared class any dialog action button carries. */
|
|
17
|
+
export const SUBMIT_DIALOG_ACTION_CLASS = 'submit-dialog-action';
|
|
18
|
+
/** The rule text, injected verbatim into the document. */
|
|
19
|
+
export const SUBMIT_DIALOG_ACTION_RULE = `.${SUBMIT_DIALOG_ACTION_CLASS} {
|
|
20
|
+
box-sizing: border-box;
|
|
21
|
+
display: inline-flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
min-inline-size: var(--pie-qti-control-min-size, 2.75rem);
|
|
25
|
+
min-block-size: var(--pie-qti-control-min-size, 2.75rem);
|
|
26
|
+
padding-block: var(--pie-qti-space-2, 0.5rem);
|
|
27
|
+
padding-inline: var(--pie-qti-space-4, 1rem);
|
|
28
|
+
border: 1px solid var(--pie-qti-border-strong, #767676);
|
|
29
|
+
border-radius: var(--pie-qti-radius, 0.5rem);
|
|
30
|
+
background: var(--pie-qti-base-100, oklch(100% 0 0));
|
|
31
|
+
color: var(--pie-qti-base-content, oklch(21% 0 0));
|
|
32
|
+
font: inherit;
|
|
33
|
+
font-weight: 600;
|
|
34
|
+
line-height: 1.25;
|
|
35
|
+
text-align: center;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.${SUBMIT_DIALOG_ACTION_CLASS}:hover:not([aria-disabled='true']) {
|
|
40
|
+
background: var(--pie-qti-base-200, oklch(98% 0 0));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.${SUBMIT_DIALOG_ACTION_CLASS}:focus-visible {
|
|
44
|
+
outline: 2px solid var(--pie-qti-focus, #4338ca);
|
|
45
|
+
outline-offset: 2px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.${SUBMIT_DIALOG_ACTION_CLASS}[aria-disabled='true'] {
|
|
49
|
+
cursor: not-allowed;
|
|
50
|
+
opacity: 0.6;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.${SUBMIT_DIALOG_ACTION_CLASS}.primary {
|
|
54
|
+
border-color: var(--pie-qti-primary, oklch(45% 0.24 277));
|
|
55
|
+
background: var(--pie-qti-primary, oklch(45% 0.24 277));
|
|
56
|
+
color: var(--pie-qti-primary-content, oklch(98% 0.01 277));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.${SUBMIT_DIALOG_ACTION_CLASS}.primary:hover:not([aria-disabled='true']) {
|
|
60
|
+
background: color-mix(in oklab, var(--pie-qti-primary, oklch(45% 0.24 277)) 85%, black);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.${SUBMIT_DIALOG_ACTION_CLASS}.danger {
|
|
64
|
+
border-color: var(--pie-qti-error-text, #b91c1c);
|
|
65
|
+
background: var(--pie-qti-error-text, #b91c1c);
|
|
66
|
+
color: oklch(98% 0.01 277);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.${SUBMIT_DIALOG_ACTION_CLASS}.danger:hover:not([aria-disabled='true']) {
|
|
70
|
+
background: color-mix(in oklab, var(--pie-qti-error-text, #b91c1c) 85%, black);
|
|
71
|
+
}`;
|
|
72
|
+
const STYLE_ATTRIBUTE = 'data-submit-dialog-action-source';
|
|
73
|
+
const STYLE_SOURCE = 'pie-qti';
|
|
74
|
+
/**
|
|
75
|
+
* Inject the rule into the document once. Safe to call repeatedly (the dialogs
|
|
76
|
+
* call it from their module scripts): later calls are no-ops when the rule is
|
|
77
|
+
* already present.
|
|
78
|
+
*/
|
|
79
|
+
export function ensureSubmitDialogActionStyles() {
|
|
80
|
+
if (typeof document === 'undefined')
|
|
81
|
+
return;
|
|
82
|
+
if (document.querySelector(`style[${STYLE_ATTRIBUTE}="${STYLE_SOURCE}"]`))
|
|
83
|
+
return;
|
|
84
|
+
const style = document.createElement('style');
|
|
85
|
+
style.setAttribute(STYLE_ATTRIBUTE, STYLE_SOURCE);
|
|
86
|
+
style.textContent = SUBMIT_DIALOG_ACTION_RULE;
|
|
87
|
+
document.head.appendChild(style);
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=submitDialogAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submitDialogAction.js","sourceRoot":"","sources":["../../src/components/submitDialogAction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,yDAAyD;AACzD,MAAM,CAAC,MAAM,0BAA0B,GAAG,sBAAsB,CAAC;AAEjE,0DAA0D;AAC1D,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,0BAA0B;;;;;;;;;;;;;;;;;;;;GAoBpE,0BAA0B;;;;GAI1B,0BAA0B;;;;;GAK1B,0BAA0B;;;;;GAK1B,0BAA0B;;;;;;GAM1B,0BAA0B;;;;GAI1B,0BAA0B;;;;;;GAM1B,0BAA0B;;EAE3B,CAAC;AAEH,MAAM,eAAe,GAAG,kCAAkC,CAAC;AAC3D,MAAM,YAAY,GAAG,SAAS,CAAC;AAE/B;;;;GAIG;AACH,MAAM,UAAU,8BAA8B;IAC7C,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO;IAC5C,IAAI,QAAQ,CAAC,aAAa,CAAC,SAAS,eAAe,KAAK,YAAY,IAAI,CAAC;QAAE,OAAO;IAClF,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9C,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;IAClD,KAAK,CAAC,WAAW,GAAG,yBAAyB,CAAC;IAC9C,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC","sourcesContent":["/**\n * The one rule family for the shell dialogs' action buttons\n * (`.submit-dialog-action`).\n *\n * The submit confirmation, the resume prompt and the leave-part warning render\n * their actions into `AssessmentDialog`'s actions area through snippets, so the\n * buttons stay in those dialogs' templates while one family here styles them\n * all: a light-DOM injection, once per document, after the idiom of\n * default-components' `shared/styles/srOnly.ts`. Every declaration lives here —\n * a dialog needing a variant adds its hook below, never as a private copy of\n * the declarations.\n *\n * The class also stays the theme hook: hosts and the component tests target\n * `submit-dialog-action`, never an injected rule's internals.\n */\n\n/** The shared class any dialog action button carries. */\nexport const SUBMIT_DIALOG_ACTION_CLASS = 'submit-dialog-action';\n\n/** The rule text, injected verbatim into the document. */\nexport const SUBMIT_DIALOG_ACTION_RULE = `.${SUBMIT_DIALOG_ACTION_CLASS} {\n\tbox-sizing: border-box;\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\tmin-inline-size: var(--pie-qti-control-min-size, 2.75rem);\n\tmin-block-size: var(--pie-qti-control-min-size, 2.75rem);\n\tpadding-block: var(--pie-qti-space-2, 0.5rem);\n\tpadding-inline: var(--pie-qti-space-4, 1rem);\n\tborder: 1px solid var(--pie-qti-border-strong, #767676);\n\tborder-radius: var(--pie-qti-radius, 0.5rem);\n\tbackground: var(--pie-qti-base-100, oklch(100% 0 0));\n\tcolor: var(--pie-qti-base-content, oklch(21% 0 0));\n\tfont: inherit;\n\tfont-weight: 600;\n\tline-height: 1.25;\n\ttext-align: center;\n\tcursor: pointer;\n}\n\n.${SUBMIT_DIALOG_ACTION_CLASS}:hover:not([aria-disabled='true']) {\n\tbackground: var(--pie-qti-base-200, oklch(98% 0 0));\n}\n\n.${SUBMIT_DIALOG_ACTION_CLASS}:focus-visible {\n\toutline: 2px solid var(--pie-qti-focus, #4338ca);\n\toutline-offset: 2px;\n}\n\n.${SUBMIT_DIALOG_ACTION_CLASS}[aria-disabled='true'] {\n\tcursor: not-allowed;\n\topacity: 0.6;\n}\n\n.${SUBMIT_DIALOG_ACTION_CLASS}.primary {\n\tborder-color: var(--pie-qti-primary, oklch(45% 0.24 277));\n\tbackground: var(--pie-qti-primary, oklch(45% 0.24 277));\n\tcolor: var(--pie-qti-primary-content, oklch(98% 0.01 277));\n}\n\n.${SUBMIT_DIALOG_ACTION_CLASS}.primary:hover:not([aria-disabled='true']) {\n\tbackground: color-mix(in oklab, var(--pie-qti-primary, oklch(45% 0.24 277)) 85%, black);\n}\n\n.${SUBMIT_DIALOG_ACTION_CLASS}.danger {\n\tborder-color: var(--pie-qti-error-text, #b91c1c);\n\tbackground: var(--pie-qti-error-text, #b91c1c);\n\tcolor: oklch(98% 0.01 277);\n}\n\n.${SUBMIT_DIALOG_ACTION_CLASS}.danger:hover:not([aria-disabled='true']) {\n\tbackground: color-mix(in oklab, var(--pie-qti-error-text, #b91c1c) 85%, black);\n}`;\n\nconst STYLE_ATTRIBUTE = 'data-submit-dialog-action-source';\nconst STYLE_SOURCE = 'pie-qti';\n\n/**\n * Inject the rule into the document once. Safe to call repeatedly (the dialogs\n * call it from their module scripts): later calls are no-ops when the rule is\n * already present.\n */\nexport function ensureSubmitDialogActionStyles(): void {\n\tif (typeof document === 'undefined') return;\n\tif (document.querySelector(`style[${STYLE_ATTRIBUTE}=\"${STYLE_SOURCE}\"]`)) return;\n\tconst style = document.createElement('style');\n\tstyle.setAttribute(STYLE_ATTRIBUTE, STYLE_SOURCE);\n\tstyle.textContent = SUBMIT_DIALOG_ACTION_RULE;\n\tdocument.head.appendChild(style);\n}\n"]}
|