@pie-players/pie-section-player 0.3.2 → 0.3.4
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 +122 -5
- package/dist/components/section-player-item-card-element.d.ts +2 -0
- package/dist/components/section-player-item-card-element.d.ts.map +1 -0
- package/dist/components/section-player-items-pane-element.d.ts +2 -0
- package/dist/components/section-player-items-pane-element.d.ts.map +1 -0
- package/dist/components/section-player-kernel-host-element.d.ts +2 -0
- package/dist/components/section-player-kernel-host-element.d.ts.map +1 -0
- package/dist/components/section-player-passage-card-element.d.ts +2 -0
- package/dist/components/section-player-passage-card-element.d.ts.map +1 -0
- package/dist/components/section-player-passages-pane-element.d.ts +2 -0
- package/dist/components/section-player-passages-pane-element.d.ts.map +1 -0
- package/dist/components/section-player-shell-element.d.ts +2 -0
- package/dist/components/section-player-shell-element.d.ts.map +1 -0
- package/dist/components/shared/outer-scrollbars.d.ts +6 -0
- package/dist/components/shared/outer-scrollbars.d.ts.map +1 -0
- package/dist/components/shared/player-action.d.ts +1 -0
- package/dist/components/shared/player-action.d.ts.map +1 -1
- package/dist/components/shared/player-preload.d.ts +5 -0
- package/dist/components/shared/player-preload.d.ts.map +1 -1
- package/dist/components/shared/section-player-card-context.d.ts +15 -0
- package/dist/components/shared/section-player-card-context.d.ts.map +1 -0
- package/dist/components/shared/section-player-props.d.ts +2 -0
- package/dist/components/shared/section-player-props.d.ts.map +1 -0
- package/dist/components/shared/section-player-readiness.d.ts +14 -0
- package/dist/components/shared/section-player-readiness.d.ts.map +1 -0
- package/dist/components/shared/section-player-runtime.d.ts +4 -4
- package/dist/components/shared/section-player-runtime.d.ts.map +1 -1
- package/dist/components/shared/section-player-view-state.d.ts +9 -0
- package/dist/components/shared/section-player-view-state.d.ts.map +1 -1
- package/dist/contracts/layout-contract.d.ts +18 -0
- package/dist/contracts/layout-contract.d.ts.map +1 -0
- package/dist/contracts/layout-parity-metadata.d.ts +4 -0
- package/dist/contracts/layout-parity-metadata.d.ts.map +1 -0
- package/dist/contracts/public-events.d.ts +25 -0
- package/dist/contracts/public-events.d.ts.map +1 -0
- package/dist/contracts/runtime-host-contract.d.ts +29 -0
- package/dist/contracts/runtime-host-contract.d.ts.map +1 -0
- package/dist/controllers/SectionController.d.ts +2 -0
- package/dist/controllers/SectionController.d.ts.map +1 -1
- package/dist/controllers/types.d.ts +21 -12
- package/dist/controllers/types.d.ts.map +1 -1
- package/dist/{index-C1goqVqV-DS7afZzq.js → index-BZq66Ke6-D8dZwpj4.js} +15064 -18442
- package/dist/index-CGEKDUBQ-C-8EFMUk.js +216 -0
- package/dist/index-DF-Dk87f-lxErM8bo.js +178 -0
- package/dist/pie-section-player.d.ts +7 -0
- package/dist/pie-section-player.d.ts.map +1 -1
- package/dist/pie-section-player.js +8474 -14014
- package/dist/player-preload-Dj2ELq_u.js +6845 -0
- package/dist/policies/guards.d.ts +3 -0
- package/dist/policies/guards.d.ts.map +1 -0
- package/dist/policies/index.d.ts +3 -0
- package/dist/policies/index.d.ts.map +1 -0
- package/dist/policies/types.d.ts +23 -0
- package/dist/policies/types.d.ts.map +1 -0
- package/dist/tool-annotation-toolbar-DJvpXk1K.js +4917 -0
- package/dist/utils/player-preload.js +1 -1
- package/package.json +54 -13
- package/dist/index-C1goqVqV.js +0 -69344
- package/dist/player-preload-CQVG0Bih.js +0 -705
- package/dist/tool-annotation-toolbar-m4Mv2j0H.js +0 -4305
- package/src/components/ItemShellElement.svelte +0 -302
- package/src/components/PassageShellElement.svelte +0 -217
- package/src/components/PieSectionPlayerBaseElement.svelte +0 -245
- package/src/components/PieSectionPlayerSplitPaneElement.svelte +0 -675
- package/src/components/PieSectionPlayerVerticalElement.svelte +0 -439
- package/src/components/shared/SectionItemCard.svelte +0 -92
- package/src/components/shared/SectionPassageCard.svelte +0 -88
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
<svelte:options
|
|
2
|
-
customElement={{
|
|
3
|
-
tag: "pie-section-player-base",
|
|
4
|
-
shadow: "open",
|
|
5
|
-
props: {
|
|
6
|
-
assessmentId: { attribute: "assessment-id", type: "String" },
|
|
7
|
-
runtime: { type: "Object", reflect: false },
|
|
8
|
-
section: { type: "Object", reflect: false },
|
|
9
|
-
sectionId: { attribute: "section-id", type: "String" },
|
|
10
|
-
attemptId: { attribute: "attempt-id", type: "String" },
|
|
11
|
-
playerType: { attribute: "player-type", type: "String" },
|
|
12
|
-
player: { type: "Object", reflect: false },
|
|
13
|
-
lazyInit: { attribute: "lazy-init", type: "Boolean" },
|
|
14
|
-
tools: { type: "Object", reflect: false },
|
|
15
|
-
accessibility: { type: "Object", reflect: false },
|
|
16
|
-
coordinator: { type: "Object", reflect: false },
|
|
17
|
-
createSectionController: { type: "Object", reflect: false },
|
|
18
|
-
isolation: { attribute: "isolation", type: "String" },
|
|
19
|
-
env: { type: "Object", reflect: false },
|
|
20
|
-
},
|
|
21
|
-
}}
|
|
22
|
-
/>
|
|
23
|
-
|
|
24
|
-
<script lang="ts">
|
|
25
|
-
import "@pie-players/pie-assessment-toolkit/components/pie-assessment-toolkit-element";
|
|
26
|
-
import {
|
|
27
|
-
createDefaultPersonalNeedsProfile,
|
|
28
|
-
} from "@pie-players/pie-assessment-toolkit";
|
|
29
|
-
import {
|
|
30
|
-
normalizeToolsConfig,
|
|
31
|
-
resolveToolsForLevel,
|
|
32
|
-
} from "@pie-players/pie-assessment-toolkit";
|
|
33
|
-
import { createEventDispatcher } from "svelte";
|
|
34
|
-
import { SectionController } from "../controllers/SectionController.js";
|
|
35
|
-
import type { SectionCompositionModel } from "../controllers/types.js";
|
|
36
|
-
import type { AssessmentSection } from "@pie-players/pie-players-shared/types";
|
|
37
|
-
import { EMPTY_COMPOSITION } from "./shared/composition.js";
|
|
38
|
-
import {
|
|
39
|
-
DEFAULT_ASSESSMENT_ID,
|
|
40
|
-
DEFAULT_ENV,
|
|
41
|
-
DEFAULT_ISOLATION,
|
|
42
|
-
DEFAULT_LAZY_INIT,
|
|
43
|
-
DEFAULT_PLAYER_TYPE,
|
|
44
|
-
type RuntimeConfig,
|
|
45
|
-
} from "./shared/section-player-runtime.js";
|
|
46
|
-
let {
|
|
47
|
-
assessmentId = DEFAULT_ASSESSMENT_ID,
|
|
48
|
-
runtime = null as RuntimeConfig | null,
|
|
49
|
-
section = null as AssessmentSection | null,
|
|
50
|
-
sectionId = "",
|
|
51
|
-
attemptId = "",
|
|
52
|
-
playerType = DEFAULT_PLAYER_TYPE,
|
|
53
|
-
player = null as Record<string, unknown> | null,
|
|
54
|
-
lazyInit = DEFAULT_LAZY_INIT,
|
|
55
|
-
tools = null as Record<string, unknown> | null,
|
|
56
|
-
accessibility = null as Record<string, unknown> | null,
|
|
57
|
-
coordinator = null as unknown,
|
|
58
|
-
createSectionController = null as unknown,
|
|
59
|
-
isolation = DEFAULT_ISOLATION,
|
|
60
|
-
env = null as Record<string, unknown> | null,
|
|
61
|
-
} = $props();
|
|
62
|
-
|
|
63
|
-
let toolkitElement = $state<any>(null);
|
|
64
|
-
let activeToolkitCoordinator = $state<any>(null);
|
|
65
|
-
let lastCompositionVersion = $state(-1);
|
|
66
|
-
type BaseSectionPlayerEvents = {
|
|
67
|
-
"composition-changed": { composition: SectionCompositionModel };
|
|
68
|
-
"toolkit-ready": Record<string, unknown>;
|
|
69
|
-
"section-ready": Record<string, unknown>;
|
|
70
|
-
"runtime-error": Record<string, unknown>;
|
|
71
|
-
"session-changed": Record<string, unknown>;
|
|
72
|
-
"runtime-owned": Record<string, unknown>;
|
|
73
|
-
"runtime-inherited": Record<string, unknown>;
|
|
74
|
-
};
|
|
75
|
-
const dispatch = createEventDispatcher<BaseSectionPlayerEvents>();
|
|
76
|
-
const effectiveAssessmentId = $derived.by(() => runtime?.assessmentId ?? assessmentId);
|
|
77
|
-
const effectivePlayerType = $derived.by(() => runtime?.playerType ?? playerType);
|
|
78
|
-
const effectivePlayer = $derived.by(() => runtime?.player ?? player);
|
|
79
|
-
const effectiveLazyInit = $derived.by(() => runtime?.lazyInit ?? lazyInit);
|
|
80
|
-
const effectiveTools = $derived.by(() => runtime?.tools ?? tools);
|
|
81
|
-
const effectiveAccessibility = $derived.by(
|
|
82
|
-
() => runtime?.accessibility ?? accessibility,
|
|
83
|
-
);
|
|
84
|
-
const effectiveCoordinator = $derived.by(() => runtime?.coordinator ?? coordinator);
|
|
85
|
-
const effectiveCreateSectionController = $derived.by(
|
|
86
|
-
() => runtime?.createSectionController ?? createSectionController,
|
|
87
|
-
);
|
|
88
|
-
const effectiveIsolation = $derived.by(() => runtime?.isolation ?? isolation);
|
|
89
|
-
const effectiveEnv = $derived.by(() => runtime?.env ?? env ?? DEFAULT_ENV);
|
|
90
|
-
let resolvedSection = $derived.by(() => {
|
|
91
|
-
if (!section) return null;
|
|
92
|
-
const sectionAny = section as any;
|
|
93
|
-
const hasExplicitPnp = Boolean(
|
|
94
|
-
sectionAny?.personalNeedsProfile || sectionAny?.settings?.personalNeedsProfile,
|
|
95
|
-
);
|
|
96
|
-
if (hasExplicitPnp) return section;
|
|
97
|
-
return {
|
|
98
|
-
...section,
|
|
99
|
-
personalNeedsProfile: createDefaultPersonalNeedsProfile(),
|
|
100
|
-
};
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
function emit<K extends keyof BaseSectionPlayerEvents>(
|
|
104
|
-
name: K,
|
|
105
|
-
detail: BaseSectionPlayerEvents[K],
|
|
106
|
-
): void {
|
|
107
|
-
dispatch(name, detail);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function handleCompositionChanged(event: Event): void {
|
|
111
|
-
const detail = (event as CustomEvent<{
|
|
112
|
-
composition?: SectionCompositionModel;
|
|
113
|
-
version?: number;
|
|
114
|
-
}>).detail;
|
|
115
|
-
const nextComposition = detail?.composition || EMPTY_COMPOSITION;
|
|
116
|
-
const nextVersion =
|
|
117
|
-
typeof detail?.version === "number"
|
|
118
|
-
? detail.version
|
|
119
|
-
: lastCompositionVersion + 1;
|
|
120
|
-
if (nextVersion === lastCompositionVersion) return;
|
|
121
|
-
lastCompositionVersion = nextVersion;
|
|
122
|
-
emit("composition-changed", {
|
|
123
|
-
composition: nextComposition,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function handleToolkitEvent(
|
|
128
|
-
event: Event,
|
|
129
|
-
eventName: Exclude<keyof BaseSectionPlayerEvents, "composition-changed">,
|
|
130
|
-
): void {
|
|
131
|
-
const detail = (event as CustomEvent).detail as Record<string, unknown>;
|
|
132
|
-
if (eventName === "toolkit-ready" && detail?.coordinator) {
|
|
133
|
-
activeToolkitCoordinator = detail.coordinator;
|
|
134
|
-
}
|
|
135
|
-
emit(eventName, detail || ({} as Record<string, unknown>));
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const normalizedToolsConfig = $derived.by(() =>
|
|
139
|
-
normalizeToolsConfig((effectiveTools || {}) as any),
|
|
140
|
-
);
|
|
141
|
-
const annotationToolbarPlacementEnabled = $derived.by(() => {
|
|
142
|
-
const levels: Array<"section" | "item" | "passage"> = [
|
|
143
|
-
"section",
|
|
144
|
-
"item",
|
|
145
|
-
"passage",
|
|
146
|
-
];
|
|
147
|
-
return levels.some((level) =>
|
|
148
|
-
resolveToolsForLevel(normalizedToolsConfig as any, level).includes(
|
|
149
|
-
"annotationToolbar",
|
|
150
|
-
),
|
|
151
|
-
);
|
|
152
|
-
});
|
|
153
|
-
const annotationToolbarProviderEnabled = $derived.by(() =>
|
|
154
|
-
activeToolkitCoordinator?.isToolEnabled?.("annotationToolbar") ??
|
|
155
|
-
((normalizedToolsConfig as any)?.providers?.annotationToolbar?.enabled !==
|
|
156
|
-
false),
|
|
157
|
-
);
|
|
158
|
-
const shouldRenderAnnotationToolbar = $derived(
|
|
159
|
-
Boolean(
|
|
160
|
-
activeToolkitCoordinator &&
|
|
161
|
-
annotationToolbarPlacementEnabled &&
|
|
162
|
-
annotationToolbarProviderEnabled,
|
|
163
|
-
),
|
|
164
|
-
);
|
|
165
|
-
let annotationToolbarModuleLoaded = $state(false);
|
|
166
|
-
|
|
167
|
-
$effect(() => {
|
|
168
|
-
if (!shouldRenderAnnotationToolbar) return;
|
|
169
|
-
if (annotationToolbarModuleLoaded) return;
|
|
170
|
-
let cancelled = false;
|
|
171
|
-
void import("@pie-players/pie-tool-annotation-toolbar")
|
|
172
|
-
.then(() => {
|
|
173
|
-
if (!cancelled) {
|
|
174
|
-
annotationToolbarModuleLoaded = true;
|
|
175
|
-
}
|
|
176
|
-
})
|
|
177
|
-
.catch(() => {
|
|
178
|
-
// Keep rendering gated if the optional module is not installed.
|
|
179
|
-
if (!cancelled) {
|
|
180
|
-
annotationToolbarModuleLoaded = false;
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
return () => {
|
|
184
|
-
cancelled = true;
|
|
185
|
-
};
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
$effect(() => {
|
|
189
|
-
if (!toolkitElement) return;
|
|
190
|
-
toolkitElement.createSectionController =
|
|
191
|
-
effectiveCreateSectionController || (() => new SectionController());
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
</script>
|
|
195
|
-
|
|
196
|
-
<pie-assessment-toolkit
|
|
197
|
-
bind:this={toolkitElement}
|
|
198
|
-
assessment-id={effectiveAssessmentId}
|
|
199
|
-
section={resolvedSection}
|
|
200
|
-
section-id={sectionId}
|
|
201
|
-
attempt-id={attemptId}
|
|
202
|
-
player-type={effectivePlayerType}
|
|
203
|
-
player={effectivePlayer}
|
|
204
|
-
env={effectiveEnv}
|
|
205
|
-
lazy-init={effectiveLazyInit}
|
|
206
|
-
tools={effectiveTools}
|
|
207
|
-
accessibility={effectiveAccessibility}
|
|
208
|
-
coordinator={effectiveCoordinator}
|
|
209
|
-
isolation={effectiveIsolation}
|
|
210
|
-
oncomposition-changed={handleCompositionChanged}
|
|
211
|
-
ontoolkit-ready={(event: Event) => handleToolkitEvent(event, "toolkit-ready")}
|
|
212
|
-
onsection-ready={(event: Event) => handleToolkitEvent(event, "section-ready")}
|
|
213
|
-
onruntime-error={(event: Event) => handleToolkitEvent(event, "runtime-error")}
|
|
214
|
-
onsession-changed={(event: Event) => handleToolkitEvent(event, "session-changed")}
|
|
215
|
-
onruntime-owned={(event: Event) => handleToolkitEvent(event, "runtime-owned")}
|
|
216
|
-
onruntime-inherited={(event: Event) => handleToolkitEvent(event, "runtime-inherited")}
|
|
217
|
-
>
|
|
218
|
-
{#if shouldRenderAnnotationToolbar && annotationToolbarModuleLoaded}
|
|
219
|
-
<pie-tool-annotation-toolbar
|
|
220
|
-
enabled={true}
|
|
221
|
-
ttsService={activeToolkitCoordinator.ttsService}
|
|
222
|
-
highlightCoordinator={activeToolkitCoordinator.highlightCoordinator}
|
|
223
|
-
></pie-tool-annotation-toolbar>
|
|
224
|
-
{/if}
|
|
225
|
-
<slot></slot>
|
|
226
|
-
</pie-assessment-toolkit>
|
|
227
|
-
|
|
228
|
-
<style>
|
|
229
|
-
:host {
|
|
230
|
-
display: block;
|
|
231
|
-
width: 100%;
|
|
232
|
-
height: 100%;
|
|
233
|
-
min-height: 0;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
pie-assessment-toolkit {
|
|
237
|
-
display: flex;
|
|
238
|
-
flex-direction: column;
|
|
239
|
-
flex: 1;
|
|
240
|
-
width: 100%;
|
|
241
|
-
height: 100%;
|
|
242
|
-
min-height: 0;
|
|
243
|
-
overflow: hidden;
|
|
244
|
-
}
|
|
245
|
-
</style>
|