@pie-players/pie-assessment-toolkit 0.2.9 → 0.2.10
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/dist/components/ItemToolBar.custom-element.js +413 -88
- package/dist/components/PieAssessmentToolkit.custom-element.js +128 -41
- package/dist/components/SectionToolBar.custom-element.js +162 -0
- package/dist/components/section-toolbar-element.d.ts +3 -0
- package/dist/components/section-toolbar-element.d.ts.map +1 -0
- package/dist/components/section-toolbar-element.js +2 -0
- package/dist/components/section-toolbar-element.js.map +1 -0
- package/dist/context/assessment-toolkit-context.d.ts +1 -1
- package/dist/context/assessment-toolkit-context.d.ts.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/SectionRuntimeEngine.d.ts +1 -1
- package/dist/runtime/SectionRuntimeEngine.d.ts.map +1 -1
- package/dist/services/HighlightCoordinator.d.ts +9 -0
- package/dist/services/HighlightCoordinator.d.ts.map +1 -1
- package/dist/services/HighlightCoordinator.js +196 -55
- package/dist/services/HighlightCoordinator.js.map +1 -1
- package/dist/services/TTSService.d.ts +18 -0
- package/dist/services/TTSService.d.ts.map +1 -1
- package/dist/services/TTSService.js +343 -105
- package/dist/services/TTSService.js.map +1 -1
- package/dist/services/ToolRegistry.d.ts +14 -2
- package/dist/services/ToolRegistry.d.ts.map +1 -1
- package/dist/services/ToolRegistry.js +2 -1
- package/dist/services/ToolRegistry.js.map +1 -1
- package/dist/services/ToolkitCoordinator.d.ts +21 -1
- package/dist/services/ToolkitCoordinator.d.ts.map +1 -1
- package/dist/services/ToolkitCoordinator.js +106 -2
- package/dist/services/ToolkitCoordinator.js.map +1 -1
- package/dist/services/createDefaultToolRegistry.d.ts +5 -11
- package/dist/services/createDefaultToolRegistry.d.ts.map +1 -1
- package/dist/services/createDefaultToolRegistry.js +5 -48
- package/dist/services/createDefaultToolRegistry.js.map +1 -1
- package/dist/services/interfaces.d.ts +1 -1
- package/dist/services/interfaces.d.ts.map +1 -1
- package/dist/services/pnp-standard-features.d.ts +1 -1
- package/dist/services/section-controller-types.d.ts +5 -0
- package/dist/services/section-controller-types.d.ts.map +1 -1
- package/dist/services/tool-config-defaults.d.ts +14 -0
- package/dist/services/tool-config-defaults.d.ts.map +1 -0
- package/dist/services/tool-config-defaults.js +23 -0
- package/dist/services/tool-config-defaults.js.map +1 -0
- package/dist/services/tool-context.d.ts.map +1 -1
- package/dist/services/tool-context.js +50 -3
- package/dist/services/tool-context.js.map +1 -1
- package/dist/services/tool-instance-id.d.ts +1 -3
- package/dist/services/tool-instance-id.d.ts.map +1 -1
- package/dist/services/tool-instance-id.js +4 -10
- package/dist/services/tool-instance-id.js.map +1 -1
- package/dist/services/toolbar-items.d.ts +26 -0
- package/dist/services/toolbar-items.d.ts.map +1 -0
- package/dist/services/toolbar-items.js +10 -0
- package/dist/services/toolbar-items.js.map +1 -0
- package/dist/services/tools-config-normalizer.d.ts.map +1 -1
- package/dist/services/tools-config-normalizer.js +5 -6
- package/dist/services/tools-config-normalizer.js.map +1 -1
- package/dist/services/tts/browser-provider.d.ts.map +1 -1
- package/dist/services/tts/browser-provider.js +201 -34
- package/dist/services/tts/browser-provider.js.map +1 -1
- package/dist/services/tts/text-processing.d.ts +17 -0
- package/dist/services/tts/text-processing.d.ts.map +1 -0
- package/dist/services/tts/text-processing.js +144 -0
- package/dist/services/tts/text-processing.js.map +1 -0
- package/dist/tools/default-tool-module-loaders.d.ts.map +1 -1
- package/dist/tools/default-tool-module-loaders.js +1 -7
- package/dist/tools/default-tool-module-loaders.js.map +1 -1
- package/dist/tools/registrations/accessibility-tools.d.ts +7 -2
- package/dist/tools/registrations/accessibility-tools.d.ts.map +1 -1
- package/dist/tools/registrations/accessibility-tools.js +21 -15
- package/dist/tools/registrations/accessibility-tools.js.map +1 -1
- package/dist/tools/registrations/calculator.d.ts.map +1 -1
- package/dist/tools/registrations/calculator.js +18 -10
- package/dist/tools/registrations/calculator.js.map +1 -1
- package/dist/tools/registrations/interaction-tools.js +4 -4
- package/dist/tools/registrations/interaction-tools.js.map +1 -1
- package/dist/tools/registrations/measurement-tools.js +4 -4
- package/dist/tools/registrations/measurement-tools.js.map +1 -1
- package/dist/tools/registrations/subject-specific-tools.js +4 -4
- package/dist/tools/registrations/subject-specific-tools.js.map +1 -1
- package/dist/tools/registrations/tts.d.ts.map +1 -1
- package/dist/tools/registrations/tts.js +161 -17
- package/dist/tools/registrations/tts.js.map +1 -1
- package/dist/tools/tool-tag-map.d.ts.map +1 -1
- package/dist/tools/tool-tag-map.js +2 -1
- package/dist/tools/tool-tag-map.js.map +1 -1
- package/package.json +11 -7
- package/src/components/ItemToolBar.svelte +254 -42
- package/src/components/PieAssessmentToolkit.svelte +139 -46
- package/src/components/SectionToolBar.svelte +58 -0
- package/dist/services/tts/provider-interface.d.ts +0 -131
- package/dist/services/tts/provider-interface.d.ts.map +0 -1
- package/dist/services/tts/provider-interface.js +0 -10
- package/dist/services/tts/provider-interface.js.map +0 -1
- package/src/components/PNPProvenanceViewer.svelte +0 -270
|
@@ -61,10 +61,14 @@
|
|
|
61
61
|
|
|
62
62
|
const runtimeId = createRuntimeId("toolkit");
|
|
63
63
|
const sectionEngine = new SectionRuntimeEngine();
|
|
64
|
+
const DEFAULT_ENV = {
|
|
65
|
+
mode: "gather",
|
|
66
|
+
role: "student",
|
|
67
|
+
} as const;
|
|
64
68
|
const DEFAULT_ITEM_PLAYER_BY_TYPE: Record<ItemPlayerType, string> = {
|
|
65
|
-
iife: "pie-
|
|
66
|
-
esm: "pie-
|
|
67
|
-
|
|
69
|
+
iife: "pie-item-player",
|
|
70
|
+
esm: "pie-item-player",
|
|
71
|
+
preloaded: "pie-item-player",
|
|
68
72
|
custom: "",
|
|
69
73
|
};
|
|
70
74
|
|
|
@@ -98,7 +102,10 @@
|
|
|
98
102
|
let compositionVersion = $state(0);
|
|
99
103
|
let compositionModel = $state<unknown>(null);
|
|
100
104
|
let runtimeError = $state<unknown>(null);
|
|
101
|
-
let
|
|
105
|
+
let lastCompositionRevisionKey = $state("");
|
|
106
|
+
let pendingCompositionModel: unknown = null;
|
|
107
|
+
let pendingCompositionEmit = false;
|
|
108
|
+
let compositionEmitRaf: number | null = null;
|
|
102
109
|
|
|
103
110
|
function getHostElement(): HTMLElement | null {
|
|
104
111
|
if (!anchor) return null;
|
|
@@ -115,8 +122,59 @@
|
|
|
115
122
|
dispatchCrossBoundaryEvent(host, name, detail);
|
|
116
123
|
}
|
|
117
124
|
|
|
125
|
+
function hashString(input: string): string {
|
|
126
|
+
let hash = 5381;
|
|
127
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
128
|
+
hash = ((hash << 5) + hash) ^ input.charCodeAt(index);
|
|
129
|
+
}
|
|
130
|
+
return (hash >>> 0).toString(36);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function getCompositionRevisionKey(model: unknown): string {
|
|
134
|
+
const typed = (model || {}) as Record<string, unknown>;
|
|
135
|
+
const sectionId =
|
|
136
|
+
((typed.section as Record<string, unknown> | undefined)?.identifier as string) ||
|
|
137
|
+
(typed.sectionId as string) ||
|
|
138
|
+
"";
|
|
139
|
+
const currentItemIndex =
|
|
140
|
+
typeof typed.currentItemIndex === "number" ? typed.currentItemIndex : -1;
|
|
141
|
+
const renderables = Array.isArray(typed.renderables) ? typed.renderables : [];
|
|
142
|
+
const renderableSignature = renderables
|
|
143
|
+
.map((entry, index) => {
|
|
144
|
+
const row = (entry || {}) as Record<string, unknown>;
|
|
145
|
+
const entity = (row.entity || {}) as Record<string, unknown>;
|
|
146
|
+
const entityId =
|
|
147
|
+
(typeof entity.id === "string" && entity.id) || `renderable-${index}`;
|
|
148
|
+
const entityVersion =
|
|
149
|
+
(typeof entity.version === "string" && entity.version) ||
|
|
150
|
+
(typeof entity.version === "number" ? String(entity.version) : "") ||
|
|
151
|
+
(typeof (entity.config as Record<string, unknown> | undefined)?.version === "string"
|
|
152
|
+
? ((entity.config as Record<string, unknown>).version as string)
|
|
153
|
+
: "");
|
|
154
|
+
return `${entityId}:${entityVersion}`;
|
|
155
|
+
})
|
|
156
|
+
.join("|");
|
|
157
|
+
const sessionsByItem = (typed.itemSessionsByItemId || {}) as Record<string, unknown>;
|
|
158
|
+
const itemSessionSignature = Object.keys(sessionsByItem)
|
|
159
|
+
.sort((left, right) => left.localeCompare(right))
|
|
160
|
+
.map((itemId) => {
|
|
161
|
+
const session = sessionsByItem[itemId] as Record<string, unknown> | undefined;
|
|
162
|
+
const sessionId = (typeof session?.id === "string" && session.id) || "";
|
|
163
|
+
const dataPayload = Array.isArray(session?.data) ? session.data : [];
|
|
164
|
+
let payloadSignature = "";
|
|
165
|
+
try {
|
|
166
|
+
payloadSignature = hashString(JSON.stringify(dataPayload));
|
|
167
|
+
} catch {
|
|
168
|
+
payloadSignature = String(dataPayload.length);
|
|
169
|
+
}
|
|
170
|
+
return `${itemId}:${sessionId}:${payloadSignature}`;
|
|
171
|
+
})
|
|
172
|
+
.join("|");
|
|
173
|
+
return `${sectionId}|${currentItemIndex}|${renderableSignature}|${itemSessionSignature}`;
|
|
174
|
+
}
|
|
175
|
+
|
|
118
176
|
function isKnownPlayerType(value: unknown): value is ItemPlayerType {
|
|
119
|
-
return value === "iife" || value === "esm" || value === "
|
|
177
|
+
return value === "iife" || value === "esm" || value === "preloaded" || value === "custom";
|
|
120
178
|
}
|
|
121
179
|
|
|
122
180
|
function normalizeItemPlayerConfig(
|
|
@@ -150,6 +208,26 @@
|
|
|
150
208
|
};
|
|
151
209
|
}
|
|
152
210
|
|
|
211
|
+
function normalizeEnv(input: unknown): { mode: string; role: string } {
|
|
212
|
+
const envValue = ((input || {}) as Record<string, unknown>) || {};
|
|
213
|
+
const mode =
|
|
214
|
+
typeof envValue.mode === "string" && envValue.mode.trim()
|
|
215
|
+
? envValue.mode.trim()
|
|
216
|
+
: DEFAULT_ENV.mode;
|
|
217
|
+
const role =
|
|
218
|
+
typeof envValue.role === "string" && envValue.role.trim()
|
|
219
|
+
? envValue.role.trim()
|
|
220
|
+
: DEFAULT_ENV.role;
|
|
221
|
+
return { mode, role };
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function resolveSectionViewFromEnv(input: unknown): string {
|
|
225
|
+
const resolvedEnv = normalizeEnv(input);
|
|
226
|
+
if (resolvedEnv.mode === "author") return "author";
|
|
227
|
+
if (resolvedEnv.role === "instructor") return "scorer";
|
|
228
|
+
return "candidate";
|
|
229
|
+
}
|
|
230
|
+
|
|
153
231
|
async function createDefaultSectionController() {
|
|
154
232
|
if (createSectionController) {
|
|
155
233
|
return createSectionController() as any;
|
|
@@ -203,6 +281,8 @@
|
|
|
203
281
|
const effectiveSectionId = $derived(
|
|
204
282
|
sectionId || (section as any)?.identifier || `section-${effectiveAssessmentId || "default"}`,
|
|
205
283
|
);
|
|
284
|
+
const effectiveEnv = $derived.by(() => normalizeEnv(env));
|
|
285
|
+
const effectiveSectionView = $derived.by(() => resolveSectionViewFromEnv(effectiveEnv));
|
|
206
286
|
const effectiveItemPlayer = $derived.by(() =>
|
|
207
287
|
normalizeItemPlayerConfig(player, playerType),
|
|
208
288
|
);
|
|
@@ -221,10 +301,10 @@
|
|
|
221
301
|
itemPlayer: effectiveItemPlayer,
|
|
222
302
|
reportSessionChanged: (itemId: string, detail: unknown) => {
|
|
223
303
|
const result = sectionEngine.handleItemSessionChanged(itemId, detail);
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
304
|
+
emitNormalizedSessionChanged({
|
|
305
|
+
itemId,
|
|
306
|
+
result,
|
|
307
|
+
fallbackSession: detail,
|
|
228
308
|
});
|
|
229
309
|
},
|
|
230
310
|
};
|
|
@@ -239,35 +319,12 @@
|
|
|
239
319
|
},
|
|
240
320
|
);
|
|
241
321
|
|
|
242
|
-
function
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
? typed.items.map((item: any) => item?.id || "")
|
|
246
|
-
: [];
|
|
247
|
-
const passageIds = Array.isArray(typed?.passages)
|
|
248
|
-
? typed.passages.map((item: any) => item?.id || "")
|
|
249
|
-
: [];
|
|
250
|
-
const sessionByItem = typed?.itemSessionsByItemId
|
|
251
|
-
? Object.entries(typed.itemSessionsByItemId)
|
|
252
|
-
.sort(([left], [right]) => left.localeCompare(right))
|
|
253
|
-
.map(([itemId, session]) => [itemId, JSON.stringify(session ?? null)])
|
|
254
|
-
: [];
|
|
255
|
-
return JSON.stringify({
|
|
256
|
-
sectionId: typed?.section?.identifier || typed?.sectionId || "",
|
|
257
|
-
currentItemIndex: typed?.currentItemIndex ?? -1,
|
|
258
|
-
itemIds,
|
|
259
|
-
passageIds,
|
|
260
|
-
sessionByItem,
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
function emitCompositionChanged() {
|
|
265
|
-
const nextModel = sectionEngine.getCompositionModel();
|
|
266
|
-
const signature = getCompositionSignature(nextModel);
|
|
267
|
-
if (signature === lastCompositionSignature) {
|
|
322
|
+
function flushCompositionChanged(nextModel: unknown) {
|
|
323
|
+
const nextRevisionKey = getCompositionRevisionKey(nextModel);
|
|
324
|
+
if (nextRevisionKey === lastCompositionRevisionKey) {
|
|
268
325
|
return;
|
|
269
326
|
}
|
|
270
|
-
|
|
327
|
+
lastCompositionRevisionKey = nextRevisionKey;
|
|
271
328
|
compositionVersion += 1;
|
|
272
329
|
compositionModel = nextModel;
|
|
273
330
|
emit("composition-changed", {
|
|
@@ -276,6 +333,38 @@
|
|
|
276
333
|
});
|
|
277
334
|
}
|
|
278
335
|
|
|
336
|
+
function emitCompositionChanged(nextModel?: unknown) {
|
|
337
|
+
pendingCompositionModel = nextModel ?? sectionEngine.getCompositionModel();
|
|
338
|
+
if (pendingCompositionEmit) return;
|
|
339
|
+
pendingCompositionEmit = true;
|
|
340
|
+
const flush = () => {
|
|
341
|
+
pendingCompositionEmit = false;
|
|
342
|
+
compositionEmitRaf = null;
|
|
343
|
+
flushCompositionChanged(pendingCompositionModel);
|
|
344
|
+
};
|
|
345
|
+
if (typeof window !== "undefined" && typeof window.requestAnimationFrame === "function") {
|
|
346
|
+
compositionEmitRaf = window.requestAnimationFrame(flush);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
queueMicrotask(flush);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function emitNormalizedSessionChanged(args: {
|
|
353
|
+
itemId: string;
|
|
354
|
+
canonicalItemId?: string;
|
|
355
|
+
result: unknown;
|
|
356
|
+
fallbackSession: unknown;
|
|
357
|
+
}) {
|
|
358
|
+
const normalized =
|
|
359
|
+
(args.result as SessionChangedLike | null)?.eventDetail || args.fallbackSession;
|
|
360
|
+
emit("session-changed", {
|
|
361
|
+
...(normalized as Record<string, unknown>),
|
|
362
|
+
itemId: args.itemId,
|
|
363
|
+
canonicalItemId: args.canonicalItemId || args.itemId,
|
|
364
|
+
sourceRuntimeId: runtimeId,
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
|
|
279
368
|
function isLocalToCurrentRuntime(eventTarget: EventTarget | null): boolean {
|
|
280
369
|
if (!(eventTarget instanceof HTMLElement)) return false;
|
|
281
370
|
const sourceRuntime = requestContext(
|
|
@@ -339,8 +428,8 @@
|
|
|
339
428
|
if (!host) return;
|
|
340
429
|
host.setAttribute("data-item-player-type", effectiveItemPlayer.type);
|
|
341
430
|
host.setAttribute("data-item-player-tag", effectiveItemPlayer.tagName);
|
|
342
|
-
host.setAttribute("data-env-mode", String((
|
|
343
|
-
host.setAttribute("data-env-role", String((
|
|
431
|
+
host.setAttribute("data-env-mode", String((effectiveEnv as any)?.mode || ""));
|
|
432
|
+
host.setAttribute("data-env-role", String((effectiveEnv as any)?.role || ""));
|
|
344
433
|
});
|
|
345
434
|
|
|
346
435
|
$effect(() => {
|
|
@@ -378,12 +467,11 @@
|
|
|
378
467
|
sectionId: effectiveSectionId,
|
|
379
468
|
assessmentId: effectiveAssessmentId,
|
|
380
469
|
attemptId: attemptId || undefined,
|
|
381
|
-
view,
|
|
470
|
+
view: effectiveSectionView,
|
|
382
471
|
createDefaultController: createDefaultSectionController,
|
|
383
472
|
onCompositionChanged: (nextComposition) => {
|
|
384
473
|
if (cancelled) return;
|
|
385
|
-
|
|
386
|
-
emitCompositionChanged();
|
|
474
|
+
emitCompositionChanged(nextComposition);
|
|
387
475
|
},
|
|
388
476
|
})
|
|
389
477
|
.then(() => {
|
|
@@ -393,6 +481,7 @@
|
|
|
393
481
|
assessmentId: effectiveAssessmentId,
|
|
394
482
|
sectionId: effectiveSectionId,
|
|
395
483
|
itemPlayer: effectiveItemPlayer,
|
|
484
|
+
coordinator: effectiveCoordinator,
|
|
396
485
|
});
|
|
397
486
|
emit("section-ready", {
|
|
398
487
|
sectionId: effectiveSectionId,
|
|
@@ -438,12 +527,11 @@
|
|
|
438
527
|
if (!detail?.itemId) return;
|
|
439
528
|
if (!shouldHandleBySourceRuntime(detail.sourceRuntimeId, runtimeId)) return;
|
|
440
529
|
const result = sectionEngine.handleItemSessionChanged(detail.itemId, detail.session);
|
|
441
|
-
|
|
442
|
-
emit("session-changed", {
|
|
443
|
-
...(normalized as Record<string, unknown>),
|
|
530
|
+
emitNormalizedSessionChanged({
|
|
444
531
|
itemId: detail.itemId,
|
|
445
|
-
canonicalItemId: detail.canonicalItemId
|
|
446
|
-
|
|
532
|
+
canonicalItemId: detail.canonicalItemId,
|
|
533
|
+
result,
|
|
534
|
+
fallbackSession: detail.session,
|
|
447
535
|
});
|
|
448
536
|
};
|
|
449
537
|
|
|
@@ -500,6 +588,11 @@
|
|
|
500
588
|
|
|
501
589
|
$effect(() => {
|
|
502
590
|
return () => {
|
|
591
|
+
if (compositionEmitRaf !== null && typeof window !== "undefined") {
|
|
592
|
+
window.cancelAnimationFrame(compositionEmitRaf);
|
|
593
|
+
compositionEmitRaf = null;
|
|
594
|
+
}
|
|
595
|
+
pendingCompositionEmit = false;
|
|
503
596
|
void sectionEngine.dispose().catch((error) => {
|
|
504
597
|
runtimeError = error;
|
|
505
598
|
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<svelte:options
|
|
2
|
+
customElement={{
|
|
3
|
+
tag: "pie-section-toolbar",
|
|
4
|
+
shadow: "none",
|
|
5
|
+
props: {
|
|
6
|
+
enabledTools: { type: "String", attribute: "enabled-tools" },
|
|
7
|
+
position: { type: "String", attribute: "position" },
|
|
8
|
+
sectionId: { type: "String", attribute: "section-id" },
|
|
9
|
+
size: { type: "String", attribute: "size" },
|
|
10
|
+
language: { type: "String", attribute: "language" },
|
|
11
|
+
toolRegistry: { type: "Object", reflect: false },
|
|
12
|
+
pnpResolver: { type: "Object", reflect: false },
|
|
13
|
+
assessment: { type: "Object", reflect: false },
|
|
14
|
+
itemRef: { type: "Object", reflect: false },
|
|
15
|
+
item: { type: "Object", reflect: false },
|
|
16
|
+
hostButtons: { type: "Object", reflect: false },
|
|
17
|
+
},
|
|
18
|
+
}}
|
|
19
|
+
/>
|
|
20
|
+
|
|
21
|
+
<script lang="ts">
|
|
22
|
+
import "./item-toolbar-element.js";
|
|
23
|
+
import type { ToolRegistry } from "../services/ToolRegistry.js";
|
|
24
|
+
import type { PNPToolResolver } from "../services/PNPToolResolver.js";
|
|
25
|
+
import type { AssessmentEntity, AssessmentItemRef, ItemEntity } from "@pie-players/pie-players-shared/types";
|
|
26
|
+
import type { ToolbarItem } from "../services/toolbar-items.js";
|
|
27
|
+
|
|
28
|
+
let {
|
|
29
|
+
enabledTools = "",
|
|
30
|
+
position = "bottom",
|
|
31
|
+
sectionId = "",
|
|
32
|
+
size = "md" as "sm" | "md" | "lg",
|
|
33
|
+
language = "en-US",
|
|
34
|
+
toolRegistry = null as ToolRegistry | null,
|
|
35
|
+
pnpResolver = null as PNPToolResolver | null,
|
|
36
|
+
assessment = null as AssessmentEntity | null,
|
|
37
|
+
itemRef = null as AssessmentItemRef | null,
|
|
38
|
+
item = null as ItemEntity | null,
|
|
39
|
+
hostButtons = [] as ToolbarItem[],
|
|
40
|
+
} = $props();
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<pie-item-toolbar
|
|
44
|
+
level="section"
|
|
45
|
+
scope-id={sectionId}
|
|
46
|
+
section-id={sectionId}
|
|
47
|
+
tools={enabledTools}
|
|
48
|
+
content-kind="section"
|
|
49
|
+
position={position}
|
|
50
|
+
{size}
|
|
51
|
+
{language}
|
|
52
|
+
{toolRegistry}
|
|
53
|
+
{pnpResolver}
|
|
54
|
+
{assessment}
|
|
55
|
+
{itemRef}
|
|
56
|
+
{item}
|
|
57
|
+
{hostButtons}
|
|
58
|
+
></pie-item-toolbar>
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TTS Provider Interfaces
|
|
3
|
-
*
|
|
4
|
-
* Defines the contract for text-to-speech providers.
|
|
5
|
-
* Providers are stateless factories that create configured TTS implementations.
|
|
6
|
-
*
|
|
7
|
-
* Part of PIE Assessment Toolkit.
|
|
8
|
-
*/
|
|
9
|
-
import type { TTSConfig } from "../TTSService.js";
|
|
10
|
-
/**
|
|
11
|
-
* TTS Provider interface
|
|
12
|
-
*
|
|
13
|
-
* Providers are stateless factories that create TTS implementations.
|
|
14
|
-
* They describe capabilities and create configured instances.
|
|
15
|
-
*/
|
|
16
|
-
export interface ITTSProvider {
|
|
17
|
-
/**
|
|
18
|
-
* Unique identifier for this provider
|
|
19
|
-
*/
|
|
20
|
-
readonly providerId: string;
|
|
21
|
-
/**
|
|
22
|
-
* Human-readable provider name
|
|
23
|
-
*/
|
|
24
|
-
readonly providerName: string;
|
|
25
|
-
/**
|
|
26
|
-
* Provider version
|
|
27
|
-
*/
|
|
28
|
-
readonly version: string;
|
|
29
|
-
/**
|
|
30
|
-
* Initialize and create a configured TTS implementation
|
|
31
|
-
*/
|
|
32
|
-
initialize(config: TTSConfig): Promise<ITTSProviderImplementation>;
|
|
33
|
-
/**
|
|
34
|
-
* Check if a specific feature is supported
|
|
35
|
-
*/
|
|
36
|
-
supportsFeature(feature: TTSFeature): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Get provider capabilities
|
|
39
|
-
*/
|
|
40
|
-
getCapabilities(): TTSProviderCapabilities;
|
|
41
|
-
/**
|
|
42
|
-
* Clean up provider resources
|
|
43
|
-
*/
|
|
44
|
-
destroy(): void;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* TTS Provider Implementation interface
|
|
48
|
-
*
|
|
49
|
-
* The actual TTS implementation that handles playback.
|
|
50
|
-
* Created by ITTSProvider.initialize()
|
|
51
|
-
*/
|
|
52
|
-
export interface ITTSProviderImplementation {
|
|
53
|
-
/**
|
|
54
|
-
* Speak text
|
|
55
|
-
*/
|
|
56
|
-
speak(text: string): Promise<void>;
|
|
57
|
-
/**
|
|
58
|
-
* Pause playback
|
|
59
|
-
*/
|
|
60
|
-
pause(): void;
|
|
61
|
-
/**
|
|
62
|
-
* Resume playback
|
|
63
|
-
*/
|
|
64
|
-
resume(): void;
|
|
65
|
-
/**
|
|
66
|
-
* Stop playback
|
|
67
|
-
*/
|
|
68
|
-
stop(): void;
|
|
69
|
-
/**
|
|
70
|
-
* Check if currently playing
|
|
71
|
-
*/
|
|
72
|
-
isPlaying(): boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Check if paused
|
|
75
|
-
*/
|
|
76
|
-
isPaused(): boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Update settings dynamically (optional)
|
|
79
|
-
* Allows changing rate, pitch, and voice without full reinitialization.
|
|
80
|
-
* Changes take effect on the next speak() call.
|
|
81
|
-
*/
|
|
82
|
-
updateSettings?(settings: Partial<TTSConfig>): void | Promise<void>;
|
|
83
|
-
/**
|
|
84
|
-
* Word boundary callback (optional)
|
|
85
|
-
* Called during speech for word highlighting
|
|
86
|
-
* @param word - The word being spoken (may be empty for server providers)
|
|
87
|
-
* @param position - Character position in the text
|
|
88
|
-
* @param length - Optional word length (for server providers with speech marks)
|
|
89
|
-
*/
|
|
90
|
-
onWordBoundary?: (word: string, position: number, length?: number) => void;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* TTS Provider capabilities
|
|
94
|
-
*
|
|
95
|
-
* Describes which features a provider supports
|
|
96
|
-
*/
|
|
97
|
-
export interface TTSProviderCapabilities {
|
|
98
|
-
/**
|
|
99
|
-
* Supports pause/resume
|
|
100
|
-
*/
|
|
101
|
-
supportsPause: boolean;
|
|
102
|
-
/**
|
|
103
|
-
* Supports resume after pause
|
|
104
|
-
*/
|
|
105
|
-
supportsResume: boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Supports word boundary events for highlighting
|
|
108
|
-
*/
|
|
109
|
-
supportsWordBoundary: boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Supports voice selection
|
|
112
|
-
*/
|
|
113
|
-
supportsVoiceSelection: boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Supports rate control (speed)
|
|
116
|
-
*/
|
|
117
|
-
supportsRateControl: boolean;
|
|
118
|
-
/**
|
|
119
|
-
* Supports pitch control
|
|
120
|
-
*/
|
|
121
|
-
supportsPitchControl: boolean;
|
|
122
|
-
/**
|
|
123
|
-
* Maximum text length (if limited)
|
|
124
|
-
*/
|
|
125
|
-
maxTextLength?: number;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* TTS features for capability checking
|
|
129
|
-
*/
|
|
130
|
-
export type TTSFeature = "pause" | "resume" | "wordBoundary" | "voiceSelection" | "rateControl" | "pitchControl";
|
|
131
|
-
//# sourceMappingURL=provider-interface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider-interface.d.ts","sourceRoot":"","sources":["../../../src/services/tts/provider-interface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC5B;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAEnE;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC;IAE9C;;OAEG;IACH,eAAe,IAAI,uBAAuB,CAAC;IAE3C;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CAChB;AAED;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;OAEG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnC;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;IAEd;;OAEG;IACH,MAAM,IAAI,IAAI,CAAC;IAEf;;OAEG;IACH,IAAI,IAAI,IAAI,CAAC;IAEb;;OAEG;IACH,SAAS,IAAI,OAAO,CAAC;IAErB;;OAEG;IACH,QAAQ,IAAI,OAAO,CAAC;IAEpB;;;;OAIG;IACH,cAAc,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpE;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3E;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACvC;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,mBAAmB,EAAE,OAAO,CAAC;IAE7B;;OAEG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GACnB,OAAO,GACP,QAAQ,GACR,cAAc,GACd,gBAAgB,GAChB,aAAa,GACb,cAAc,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TTS Provider Interfaces
|
|
3
|
-
*
|
|
4
|
-
* Defines the contract for text-to-speech providers.
|
|
5
|
-
* Providers are stateless factories that create configured TTS implementations.
|
|
6
|
-
*
|
|
7
|
-
* Part of PIE Assessment Toolkit.
|
|
8
|
-
*/
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=provider-interface.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider-interface.js","sourceRoot":"","sources":["../../../src/services/tts/provider-interface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|